1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-22 05:39:43 +00:00

Merge branch 'lua_real_time' into 'master'

[Lua] core.getRealTime()

See merge request OpenMW/openmw!1880
This commit is contained in:
psi29a 2022-05-22 10:38:53 +00:00
commit e64b8d1fbb
2 changed files with 11 additions and 0 deletions

View file

@ -1,5 +1,7 @@
#include "luabindings.hpp"
#include <chrono>
#include <components/lua/luastate.hpp>
#include <components/lua/l10n.hpp>
@ -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<double>(std::chrono::steady_clock::now().time_since_epoch()).count();
};
if (!global)
return;

View file

@ -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