diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index 4878e0423e..c9bf99462a 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -1,5 +1,7 @@ #include "luabindings.hpp" +#include + #include #include @@ -23,6 +25,10 @@ namespace MWLua api["getGameTime"] = [world=context.mWorldView]() { return world->getGameTime(); }; api["getGameTimeScale"] = [world=context.mWorldView]() { return world->getGameTimeScale(); }; api["isWorldPaused"] = [world=context.mWorldView]() { return world->isPaused(); }; + api["getRealTime"] = []() + { + return std::chrono::duration(std::chrono::steady_clock::now().time_since_epoch()).count(); + }; if (!global) return; diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index d719853da0..659a17beb1 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -46,6 +46,11 @@ -- @function [parent=#core] isWorldPaused -- @return #boolean +--- +-- Real time in seconds; starting point is not fixed (can be time since last reboot), use only for measuring intervals. For Unix time use `os.time()`. +-- @function [parent=#core] getRealTime +-- @return #number + --- -- Get a GMST setting from content files. -- @function [parent=#core] getGMST