From 8f85c9194dd92c5f49dcd11fff16be2c88d5d2c5 Mon Sep 17 00:00:00 2001 From: Cody Glassman Date: Tue, 26 Dec 2023 09:15:50 -0800 Subject: [PATCH] lua - add bindings to get frame duration --- apps/openmw/mwlua/luabindings.cpp | 1 + files/lua_api/openmw/core.lua | 5 +++++ files/lua_api/openmw/world.lua | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index a50459502b..6331bc5466 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -86,6 +86,7 @@ namespace MWLua api["getRealTime"] = []() { return std::chrono::duration(std::chrono::steady_clock::now().time_since_epoch()).count(); }; + api["getRealFrameDuration"] = []() { return MWBase::Environment::get().getFrameDuration(); }; if (!global) return; diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 18898b5002..f42f51b9b3 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -55,6 +55,11 @@ -- @function [parent=#core] getRealTime -- @return #number +--- +-- Frame duration in seconds +-- @function [parent=#core] getRealFrameDuration +-- @return #number + --- -- Get a GMST setting from content files. -- @function [parent=#core] getGMST diff --git a/files/lua_api/openmw/world.lua b/files/lua_api/openmw/world.lua index 5baa624c5d..404b744eb8 100644 --- a/files/lua_api/openmw/world.lua +++ b/files/lua_api/openmw/world.lua @@ -111,6 +111,11 @@ -- @function [parent=#world] setGameTimeScale -- @param #number ratio +--- +-- Frame duration in seconds +-- @function [parent=#world] getRealFrameDuration +-- @return #number + --- -- Whether the world is paused (onUpdate doesn't work when the world is paused). -- @function [parent=#world] isWorldPaused