diff options
| -rwxr-xr-x | SuperTimer/SuperTimer.dds | bin | 0 -> 13584 bytes | |||
| -rwxr-xr-x | SuperTimer/SuperTimer.lua | 154 | ||||
| -rwxr-xr-x | SuperTimer/SuperTimer.modinfo | 33 | ||||
| -rwxr-xr-x | SuperTimer/SuperTimer.png | bin | 0 -> 385303 bytes | |||
| -rwxr-xr-x | SuperTimer/SuperTimer.xml | 4 |
5 files changed, 191 insertions, 0 deletions
diff --git a/SuperTimer/SuperTimer.dds b/SuperTimer/SuperTimer.dds Binary files differnew file mode 100755 index 0000000..5c0d64d --- /dev/null +++ b/SuperTimer/SuperTimer.dds diff --git a/SuperTimer/SuperTimer.lua b/SuperTimer/SuperTimer.lua new file mode 100755 index 0000000..d93dbbd --- /dev/null +++ b/SuperTimer/SuperTimer.lua @@ -0,0 +1,154 @@ +-- check yor installed steam mods for reference here: \steamapps\workshop\content\289070
+-- events: -- https://forums.civfanatics.com/threads/list-of-game-events.604914/#post-14561939
+-- put your mod in: C:\Users\Miguel\Documents\My Games\Sid Meier's Civilization VI\Mods\SuperTimer
+-- lua log is here: /Documents and Settings/Miguel/My Documents/My Games/Sid Meier's Civilization VI/Logs
+-- Icon codes: https://forums.civfanatics.com/threads/list-of-all-icon-codes.613516/
+-- lua objects: https://forums.civfanatics.com/threads/lua-objects.601146/
+-- persistance:
+-- they're not saved, but see
+-- https://forums.civfanatics.com/threads/lua-objects.601146/page-4#post-14634018
+-- https://forums.civfanatics.com/threads/saving-loading-simple-tables-with-a-game.609397/
+-- https://forums.civfanatics.com/threads/persisting-custom-data-with-saves.611878/
+-- this lua file, will be auto-reloaded on change by civ6
+
+verbose = false
+
+function log( txt )
+ if verbose then print ( '[' .. os.time() .. ']' .. " [SuperTimer] " .. txt ); end
+end
+
+function getState()
+ state = GameConfiguration.GetValue ("SuperTimerState")
+ if state == nil
+ then
+ GameConfiguration.SetValue ("SuperTimerState","")
+ return ""
+ else
+ return state
+ end
+end
+
+function split(s, delimiter)
+ result = {};
+ for match in (s..delimiter):gmatch("(.-)"..delimiter) do
+ table.insert(result, match);
+ end
+ return result;
+end
+
+function toEvent(event, turn)
+ if event == "B" then return "Turn " .. turn .. " begins" end
+ if event == "E" then return "Turn ends" end
+ if event == "S" then return "Game Saved" end
+ if event == "L" then return "Game Loaded" end
+ return "Unknown Event"
+end
+
+function addState( state, turn )
+
+ newstate = getState() .. os.time() .. " " .. turn .. " " .. state .. "|";
+ GameConfiguration.SetValue ("SuperTimerState",newstate);
+ tooltip = "[ICON_Capital]Miguel's SuperTimer[ICON_Capital][NEWLINE]"
+
+ lastturn=0
+ lastevent=0;
+ sumtime=0;
+
+ for m in (newstate):gmatch("(.-)".."|") do
+ spl = split(m," ")
+ unixtime = tonumber(spl[1]);
+ turn = tonumber(spl[2]);
+ event = spl[3];
+ if event == "B" then lastturn = turn - 1 end
+ if event == "L"
+ then
+ lastevent = unixtime;
+ else
+ sumtime = sumtime + ( unixtime-lastevent );
+ log (sumtime);
+ lastevent = unixtime;
+ end
+
+ t = os.date("*t", unixtime)
+ txt = toEvent(event,spl[2]);
+ log (t.hour .. ":" .. t.min .. ":" .. t.sec .. " " .. txt)
+ end
+ log("Total: " .. sumtime .. " seconds");
+ log("Total: " .. os.date('!%T', sumtime));
+ if lastturn == 0
+ then
+ tooltip = "[ICON_Capital]Miguel's SuperTimer[ICON_Capital]" ..
+ "[NEWLINE]Complete first turn to collect data"
+ else
+ tooltip = "[ICON_Capital]Miguel's SuperTimer[ICON_Capital]" ..
+ "[NEWLINE]Turns Completed:" .. lastturn ..
+ "[NEWLINE]Total Time: " .. os.date('!%T', sumtime) ..
+ "[NEWLINE]Average Turn: " .. os.date('!%T', sumtime/lastturn);
+ end
+
+ if Controls.SuperTimerButton ~= nil
+ then
+ Controls.SuperTimerButton:SetToolTipString (tooltip);
+ end
+end
+
+
+function mouseOverTimer()
+ log ( "mouseOverTimer" );
+end
+
+
+function Initialise()
+ log ( "Game started/loaded" );
+ addState( "L" , 0 );
+ local topPanel = ContextPtr:LookUpControl("/InGame/TopPanel/RightContents");
+ Controls.SuperTimerButton:ChangeParent(topPanel);
+ topPanel:AddChildAtIndex(Controls.SuperTimerButton, 0);
+ topPanel:CalculateSize();
+ topPanel:ReprocessAnchoring();
+ Controls.SuperTimerButton:RegisterCallback( Mouse.eMouseEnter, mouseOverTimer);
+end
+
+function OnTurnBegin( turn )
+ addState( "B" , turn )
+end
+
+function OnTurnEnd()
+ addState( "E" , 0 );
+end
+
+function OnPlayerTurnEnd( player )
+end
+
+function SaveList()
+ log( "Show Savegame List" );
+ addState( "S" , 0 );
+end
+
+function SaveButton ( actionID )
+ log( "InputAction" );
+ if actionID == Input.GetActionId("QuickSave") then
+ addState( "S" , 0 );
+ end
+end
+
+function SaveKey ( pInputStruct:table )
+ log( "InputHandler" );
+ local uiMsg = pInputStruct:GetMessageType();
+ if uiMsg == KeyEvents.KeyDown then
+ if pInputStruct:GetKey() == Keys.VK_F5 then -- but the binding can be changed...
+ addState( "S" , 0 );
+ end
+ end
+end
+
+log ( "Mod Loaded" );
+
+--- EVENTS
+LuaEvents.FileListQueryComplete.Add( SaveList );
+Events.InputActionTriggered.Add( SaveButton );
+ContextPtr:SetInputHandler( SaveKey, true ); -- does not work ?
+Events.LoadScreenClose.Add( Initialise );
+Events.TurnBegin.Add( OnTurnBegin );
+Events.LocalPlayerTurnEnd.Add( OnTurnEnd );
+Events.RemotePlayerTurnEnd.Add( OnPlayerTurnEnd );
diff --git a/SuperTimer/SuperTimer.modinfo b/SuperTimer/SuperTimer.modinfo new file mode 100755 index 0000000..02c3ca3 --- /dev/null +++ b/SuperTimer/SuperTimer.modinfo @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Mod id="2c20a448-3367-4d72-86e2-2ea480c22fcc" version="1">
+ <Properties>
+ <Name>SuperTimer</Name>
+ <Description>Count playtime!</Description>
+ <Teaser>Monitor playing time</Teaser>
+ <Authors>Michal Idziorek</Authors>
+ <Homepage>https://idziorek.net</Homepage>
+ <AffectsSavedGames>0</AffectsSavedGames>
+ <CompatibleVersions>1.2,2.0</CompatibleVersions>
+ </Properties>
+ <InGameActions>
+ <AddUserInterfaces id="SuperTimerUI">
+ <Properties>
+ <Context>InGame</Context>
+ <LoadOrder>14000</LoadOrder>
+ </Properties>
+ <File>SuperTimer.xml</File>
+ </AddUserInterfaces>
+ <ImportFiles id="SuperTimerIcon">
+ <Properties>
+ <Context>InGame</Context>
+ <LoadOrder>400</LoadOrder>
+ </Properties>
+ <File>SuperTimer.dds</File>
+ </ImportFiles>
+ </InGameActions>
+ <Files>
+ <File>SuperTimer.lua</File>
+ <File>SuperTimer.xml</File>
+ <File>SuperTimer.dds</File>
+ </Files>
+</Mod>
diff --git a/SuperTimer/SuperTimer.png b/SuperTimer/SuperTimer.png Binary files differnew file mode 100755 index 0000000..3065225 --- /dev/null +++ b/SuperTimer/SuperTimer.png diff --git a/SuperTimer/SuperTimer.xml b/SuperTimer/SuperTimer.xml new file mode 100755 index 0000000..1315b52 --- /dev/null +++ b/SuperTimer/SuperTimer.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Context>
+<Button Size="29,29" ID="SuperTimerButton" Texture="SuperTimer.dds" Anchor="C,C" ConsumeMouse="1" ToolTip="Tippy"/>
+</Context>
|
