mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-30 04:40:54 +02:00
new module - game pause
this module pauses the game whenever the last player leaves the game, ensuring that rcon does not progress the map.
This commit is contained in:
parent
fad556abb6
commit
4ee808e6f3
@ -6,6 +6,7 @@ _DUMP_ENV = false
|
||||
require 'utils.server'
|
||||
require 'utils.server_commands'
|
||||
require 'utils.utils'
|
||||
require 'utils.pause_game'
|
||||
require 'utils.table'
|
||||
require 'utils.freeplay'
|
||||
require 'utils.datastore.server_ups'
|
||||
|
35
utils/pause_game.lua
Normal file
35
utils/pause_game.lua
Normal file
@ -0,0 +1,35 @@
|
||||
local Event = require 'utils.event'
|
||||
|
||||
local function halt_game()
|
||||
game.tick_paused = true
|
||||
end
|
||||
|
||||
local function resume_game()
|
||||
game.tick_paused = false
|
||||
end
|
||||
|
||||
local function player_left()
|
||||
local player_count = #game.connected_players
|
||||
|
||||
if player_count == 0 then
|
||||
halt_game()
|
||||
end
|
||||
end
|
||||
|
||||
local function player_joined()
|
||||
resume_game()
|
||||
end
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function()
|
||||
player_joined()
|
||||
end
|
||||
)
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_left_game,
|
||||
function()
|
||||
player_left()
|
||||
end
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user