Skip to content

Commit 00515b5

Browse files
author
Credomane
committed
Fix factorio moving game.daytime to individual surfaces.
1 parent 568f294 commit 00515b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Files/control.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ script.on_event(defines.events.on_gui_click, function(event)
6363

6464
-- BUTTON SET DAYTIME
6565
if(event.element.name == "setdaytime") then
66-
currentdaytime = game.daytime
67-
game.daytime = 0
66+
currentdaytime = game.players[event.player_index].surface.daytime;
67+
game.players[event.player_index].surface.daytime = 0
6868
end
6969
-- BUTTON RESET DAYTIME
7070
if(event.element.name == "resetdaytime") then
7171
if(currentdaytime ~= nil) then
72-
game.daytime = currentdaytime
72+
--Time has advanced since we stored the time.
73+
--Add stored time to current surface time to keep ticks and day/night cycle in "sync".
74+
currentdaytime = currentdaytime + game.players[event.player_index].surface.daytime;
75+
if currentdaytime > 1 then currentdaytime = currentdaytime - 1; end
76+
game.players[event.player_index].surface.daytime = currentdaytime
7377
end
7478
end
7579

0 commit comments

Comments
 (0)