Make time per-scene

This commit is contained in:
mid 2025-06-28 13:18:24 +03:00
parent 309af8f59e
commit 446ff24fcf
2 changed files with 6 additions and 4 deletions

View File

@ -2417,7 +2417,7 @@ static int dagame_mdl_desc_append(lua_State *L) {
}
static int os_time(lua_State *L) {
lua_pushnumber(L, glfwGetTime() - LuaapiStartTime);
lua_pushnumber(L, isnan(LuaapiStartTime) ? 0 : glfwGetTime() - LuaapiStartTime);
return 1;
}
@ -3129,6 +3129,8 @@ void luaapi_init() {
}
void luaapi_load(const char *name) {
LuaapiStartTime = NAN;
lua_getglobal(L, "require");
lua_pushstring(L, name);
if(lua_pcall(L, 1, 1, 0) != LUA_OK) {
@ -3139,7 +3141,7 @@ void luaapi_load(const char *name) {
lua_getfield(L, -1, "load");
if(lua_pcall(L, 0, 0, 0) != LUA_OK) {
puts(lua_tostring(L, -1));
k3Log(k3_ERR, "%s", lua_tostring(L, -1));
lua_pop(L, 1);
return;
}
@ -3147,6 +3149,8 @@ void luaapi_load(const char *name) {
if(Game.isAuthority) {
luaapi_join(NULL, 0);
}
LuaapiStartTime = glfwGetTime();
}
void luaapi_render(double dt, double alpha) {

View File

@ -416,8 +416,6 @@ int main(int argc_, char **argv_) {
eng_ui_init();
LuaapiStartTime = glfwGetTime();
LastTime = glfwGetTime();
double accumulator = 0;