Add a time function.

This commit is contained in:
2026-01-14 15:07:56 -05:00
parent d533a8da0e
commit 264dd5e8be
2 changed files with 10 additions and 1 deletions

View File

@@ -654,6 +654,14 @@ LuaDefine(tangible_start, "tangible,function,arg1,arg2...",
return LS.result();
}
LuaDefine(time, "",
"|Get the elapsed time in ticks since the world started running.") {
World *w = World::fetch_global_pointer(L);
LuaRet time;
LuaDefStack LS(L, time);
LS.set(time, w->clock_);
return LS.result();
}
LuaDefine(wait, "nticks",
"|Wait the specified number of ticks.") {
@@ -873,7 +881,7 @@ LuaDefine(pprintx, "options",
"| value - the object to pretty-print"
"| indent - if false, suppress newlines and indentation (default: true)"
"| level - base level of indentation (default: zero)"
"| expand - if true, force expansion of top-level table (default: false)"
"| expand - if true, force expansion of top-level table (default: true)"
"|"
"|About the expand flag: normally, when you print a class, it just "
"|prints '<class name>', and when you print a tangible, it just"

View File

@@ -685,6 +685,7 @@ private:
friend int lfn_tangible_start(lua_State *L);
friend int lfn_math_random(lua_State *L);
friend int lfn_math_randomstate(lua_State *L);
friend int lfn_time(lua_State *L);
friend int lfn_wait(lua_State *L);
friend int lfn_nopredict(lua_State *L);
friend int lfn_http_request(lua_State *L, const char *method);