1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-24 03:47:58 +02:00

118 lines
3.7 KiB
Lua
Raw Normal View History

2020-07-12 20:54:44 +02:00
local Server = require 'utils.server'
2021-11-26 13:48:49 +01:00
local Public = require 'maps.fish_defender_v2.table'
2020-07-12 20:54:44 +02:00
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
commands.add_command(
'scenario',
2020-07-12 20:54:44 +02:00
'Usable only for admins - controls the scenario!',
function(cmd)
local p
local player = game.player
if not player or not player.valid then
p = log
else
p = player.print
if not player.admin then
return
end
end
local param = cmd.parameter
if param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
goto continue
else
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
return
end
::continue::
2021-11-26 13:48:49 +01:00
local this = Public.get()
2020-07-12 20:54:44 +02:00
local reset_map = require 'maps.fish_defender_v2.main'.reset_game
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
p('[WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this!')
2020-07-12 20:54:44 +02:00
return
end
if param == 'restart' then
if this.restart then
this.reset_are_you_sure = nil
this.restart = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
return
else
this.reset_are_you_sure = nil
this.restart = true
this.soft_reset = false
if this.shutdown then
this.shutdown = false
end
p('[WARNING] Soft-reset is disabled! Server will restart from scenario.')
return
end
elseif param == 'restartnow' then
this.reset_are_you_sure = nil
p(player.name .. ' has restarted the game.')
Server.start_scenario('Fish_Defender')
2020-07-12 20:54:44 +02:00
return
elseif param == 'shutdown' then
if this.shutdown then
this.reset_are_you_sure = nil
this.shutdown = false
this.soft_reset = true
p('[SUCCESS] Soft-reset is enabled.')
return
else
this.reset_are_you_sure = nil
this.shutdown = true
this.soft_reset = false
if this.restart then
this.restart = false
end
p('[WARNING] Soft-reset is disabled! Server will shutdown.')
return
end
elseif param == 'reset' then
this.reset_are_you_sure = nil
if player and player.valid then
game.print(mapkeeper .. ' ' .. player.name .. ', has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
else
game.print(mapkeeper .. ' server, has reset the game!', {r = 0.98, g = 0.66, b = 0.22})
end
reset_map()
p('[WARNING] Game has been reset!')
return
end
end
)
2020-11-10 17:39:33 +01:00
commands.add_command(
'stop_generate_map',
'Usable only for admins - controls the scenario!',
function()
local player = game.player
2021-03-24 19:14:12 +01:00
if player and player.valid then
2020-11-10 17:39:33 +01:00
if not player.admin then
return
end
end
2021-03-24 19:14:12 +01:00
2021-11-26 13:48:49 +01:00
local stop_generating_map = Public.get('stop_generating_map')
2020-11-10 17:39:33 +01:00
if not stop_generating_map then
2021-11-26 13:48:49 +01:00
Public.set('stop_generating_map', true)
2020-11-10 17:39:33 +01:00
player.print('Stopped generating the map!')
else
2021-11-26 13:48:49 +01:00
Public.set('stop_generating_map', false)
2020-11-10 17:39:33 +01:00
player.print('Resumed the generation of map!')
end
end
)
2021-11-26 13:48:49 +01:00
return Public