- [NEW] sys.chrono()
This commit is contained in:
12
lua.cpp
12
lua.cpp
@@ -699,6 +699,17 @@ extern "C" {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint32_t chrono_time = 0;
|
||||
static int cpp_sys_chrono(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushnumber(L, float(SDL_GetTicks()-chrono_time)/1000.0f);
|
||||
return 1;
|
||||
} else {
|
||||
chrono_time = SDL_GetTicks();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int cpp_sys_beat(lua_State *L) {
|
||||
if (lua_gettop(L) == 0) {
|
||||
lua_pushboolean(L, beat(-1));
|
||||
@@ -1049,6 +1060,7 @@ void push_lua_funcs() {
|
||||
lua_newtable(L);
|
||||
lua_pushcfunction(L,cpp_sys_delta); lua_setfield(L, -2, "delta");
|
||||
lua_pushcfunction(L,cpp_sys_time); lua_setfield(L, -2, "time");
|
||||
lua_pushcfunction(L,cpp_sys_chrono); lua_setfield(L, -2, "chrono");
|
||||
lua_pushcfunction(L,cpp_sys_beat); lua_setfield(L, -2, "beat");
|
||||
lua_pushcfunction(L,cpp_sys_update); lua_setfield(L, -2, "update");
|
||||
lua_pushcfunction(L,cpp_sys_dir); lua_setfield(L, -2, "dir");
|
||||
|
||||
Reference in New Issue
Block a user