Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/guides/lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions src/program/lua/Movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};

Expand Down Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions src/program/lua/Movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down