diff --git a/aegisub/src/auto4_lua.cpp b/aegisub/src/auto4_lua.cpp index e3083b9a0..aed29752d 100644 --- a/aegisub/src/auto4_lua.cpp +++ b/aegisub/src/auto4_lua.cpp @@ -261,6 +261,7 @@ namespace Automation4 { set_field(L, "frame_from_ms", LuaFrameFromMs); set_field(L, "ms_from_frame", LuaMsFromFrame); set_field(L, "video_size", LuaVideoSize); + set_field(L, "keyframes", LuaGetKeyframes); set_field(L, "lua_automation_version", 4); // store aegisub table to globals @@ -496,6 +497,20 @@ namespace Automation4 { } } + int LuaScript::LuaGetKeyframes(lua_State *L) + { + const agi::Context *c = get_context(L); + std::vector const& kf = c->videoController->GetKeyFrames(); + + lua_newtable(L); + for (size_t i = 0; i < kf.size(); ++i) { + lua_pushinteger(L, kf[i]); + lua_rawseti(L, -2, i); + } + + return 1; + } + static void lua_threaded_call(ProgressSink *ps, lua_State *L, int nargs, int nresults, bool can_open_config, bool *failed) { LuaProgressSink lps(L, ps, can_open_config); diff --git a/aegisub/src/auto4_lua.h b/aegisub/src/auto4_lua.h index 6a49e3b7c..d78fbd463 100644 --- a/aegisub/src/auto4_lua.h +++ b/aegisub/src/auto4_lua.h @@ -309,6 +309,7 @@ namespace Automation4 { static int LuaFrameFromMs(lua_State *L); static int LuaMsFromFrame(lua_State *L); static int LuaVideoSize(lua_State *L); + static int LuaGetKeyframes(lua_State *L); public: LuaScript(const wxString &filename);