From 264dd5e8be9cd023f1aac20205b6c3adb37ed8b2 Mon Sep 17 00:00:00 2001 From: jyelon Date: Wed, 14 Jan 2026 15:07:56 -0500 Subject: [PATCH] Add a time function. --- luprex/cpp/core/world-accessor.cpp | 10 +++++++++- luprex/cpp/core/world.hpp | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/luprex/cpp/core/world-accessor.cpp b/luprex/cpp/core/world-accessor.cpp index 1afc7bc1..d9b4cb75 100644 --- a/luprex/cpp/core/world-accessor.cpp +++ b/luprex/cpp/core/world-accessor.cpp @@ -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 '', and when you print a tangible, it just" diff --git a/luprex/cpp/core/world.hpp b/luprex/cpp/core/world.hpp index 3e85c094..6c71a05e 100644 --- a/luprex/cpp/core/world.hpp +++ b/luprex/cpp/core/world.hpp @@ -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);