diff --git a/docs/guides/lua.md b/docs/guides/lua.md index c46484b1..8d365494 100644 --- a/docs/guides/lua.md +++ b/docs/guides/lua.md @@ -304,6 +304,20 @@ Returns 1 of the current frame is a draw frame, or 0 if not. Returns the full name of the movie file (.ltm). +#### movie.getInitialSystemTime + + (Number seconds, Number nseconds) movie.getInitialSystemTime() + +Returns the system time set at game startup. `seconds` is in whole seconds +and `nseconds` is the number of nanoseconds. + +#### movie.getInitialElapsedTime + + (Number seconds, Number nseconds) movie.getInitialElapsedTime() + +Returns the elapsed time set at game startup. `seconds` is in whole seconds +and `nseconds` is the number of nanoseconds. + ### Runtime functions Runtime functions must be performed in callback `onFrame()` to be effective on diff --git a/src/program/lua/Movie.cpp b/src/program/lua/Movie.cpp index 6fa6252c..31aeba99 100644 --- a/src/program/lua/Movie.cpp +++ b/src/program/lua/Movie.cpp @@ -39,6 +39,8 @@ static const luaL_Reg movie_functions[] = { "rerecords", Lua::Movie::rerecords}, { "isDraw", Lua::Movie::isDraw}, { "getMovieFileName", Lua::Movie::getMovieFileName}, + { "getInitialSystemTime", Lua::Movie::getInitialSystemTime}, + { "getInitialElapsedTime", Lua::Movie::getInitialElapsedTime}, { NULL, NULL } }; @@ -97,3 +99,17 @@ int Lua::Movie::getMovieFileName(lua_State *L) lua_pushstring(L, context->config.moviefile.c_str()); return 1; } + +int Lua::Movie::getInitialSystemTime(lua_State *L) +{ + lua_pushinteger(L, context->config.sc.initial_time_sec); + lua_pushinteger(L, context->config.sc.initial_time_nsec); + return 2; +} + +int Lua::Movie::getInitialElapsedTime(lua_State *L) +{ + lua_pushinteger(L, context->config.sc.initial_monotonic_time_sec); + lua_pushinteger(L, context->config.sc.initial_monotonic_time_nsec); + return 2; +} diff --git a/src/program/lua/Movie.h b/src/program/lua/Movie.h index ef0a5162..37b46566 100644 --- a/src/program/lua/Movie.h +++ b/src/program/lua/Movie.h @@ -54,6 +54,11 @@ namespace Movie { /* Get filename of the movie file (.ltm) */ int getMovieFileName(lua_State *L); + /* Get system time set at game start */ + int getInitialSystemTime(lua_State *L); + + /* Get elapsed time set at game start */ + int getInitialElapsedTime(lua_State *L); } }