From 47d5868e2ccd208287a3e560c9fa7bb021db00f5 Mon Sep 17 00:00:00 2001 From: uramer Date: Tue, 30 Jan 2024 22:05:41 +0100 Subject: [PATCH] creationTime field in save info --- apps/openmw/mwlua/menuscripts.cpp | 7 +++++++ files/lua_api/openmw/menu.lua | 1 + 2 files changed, 8 insertions(+) diff --git a/apps/openmw/mwlua/menuscripts.cpp b/apps/openmw/mwlua/menuscripts.cpp index e4a3962912..033e56ac97 100644 --- a/apps/openmw/mwlua/menuscripts.cpp +++ b/apps/openmw/mwlua/menuscripts.cpp @@ -89,6 +89,13 @@ namespace MWLua sol::table contentFiles(lua, sol::create); for (size_t i = 0; i < slot.mProfile.mContentFiles.size(); ++i) contentFiles[i + 1] = Misc::StringUtils::lowerCase(slot.mProfile.mContentFiles[i]); + + { + auto system_time = std::chrono::system_clock::now() + - (std::filesystem::file_time_type::clock::now() - slot.mTimeStamp); + slotInfo["creationTime"] = std::chrono::duration(system_time.time_since_epoch()).count(); + } + slotInfo["contentFiles"] = contentFiles; saves[slot.mPath.filename().string()] = slotInfo; } diff --git a/files/lua_api/openmw/menu.lua b/files/lua_api/openmw/menu.lua index 4deb5d00a3..b443a983c9 100644 --- a/files/lua_api/openmw/menu.lua +++ b/files/lua_api/openmw/menu.lua @@ -51,6 +51,7 @@ -- @field #string playerName -- @field #string playerLevel -- @field #number timePlayed Gameplay time for this saved game. Note: available even with [time played](../modding/settings/saves.html#timeplayed) turned off +-- @field #number creationTime Time at which the game was saved, as a timestamp in seconds. Can be passed as the second argument to `os.data`. -- @field #list<#string> contentFiles ---