1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2024-12-30 23:17:53 +02:00
ComfyFactorio/maps/mountain_fortress_v3/commands.lua

146 lines
4.5 KiB
Lua
Raw Normal View History

2020-05-17 12:23:55 +02:00
local Color = require 'utils.color_presets'
local Task = require 'utils.task'
2020-06-25 17:59:16 +02:00
local Server = require 'utils.server'
2020-05-17 12:23:55 +02:00
local WPT = require 'maps.mountain_fortress_v3.table'
local mapkeeper = '[color=blue]Mapkeeper:[/color]'
commands.add_command(
2020-10-19 20:21:27 +02:00
'scenario',
2020-06-07 23:25:01 +02:00
'Usable only for admins - controls the scenario!',
function(cmd)
2020-05-17 12:23:55 +02:00
local p
local player = game.player
2020-06-07 23:25:01 +02:00
if not player or not player.valid then
p = log
else
p = player.print
if not player.admin then
return
2020-05-17 12:23:55 +02:00
end
end
2020-05-20 09:09:39 +02:00
local this = WPT.get()
2020-06-07 23:25:01 +02:00
local reset_map = require 'maps.mountain_fortress_v3.main'.reset_map
2020-05-23 21:18:18 +02:00
local param = cmd.parameter
2020-05-17 12:23:55 +02:00
2020-06-25 17:59:16 +02:00
if param == 'restart' or param == 'shutdown' or param == 'reset' or param == 'restartnow' then
2020-06-07 23:25:01 +02:00
goto continue
else
2020-06-25 17:59:16 +02:00
p('[ERROR] Arguments are:\nrestart\nshutdown\nreset\nrestartnow')
2020-06-07 23:25:01 +02:00
return
end
2020-05-23 21:18:18 +02:00
2020-06-07 23:25:01 +02:00
::continue::
2020-05-23 21:18:18 +02:00
2020-06-07 23:25:01 +02:00
if not this.reset_are_you_sure then
this.reset_are_you_sure = true
2020-12-28 11:48:25 +02:00
p('[WARNING] This command will disable the soft-reset feature, run this command again if you really want to do this!')
2020-06-07 23:25:01 +02:00
return
end
2020-05-23 21:18:18 +02:00
2020-06-07 23:25:01 +02:00
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
2020-05-17 12:23:55 +02:00
else
2020-06-07 23:25:01 +02:00
this.reset_are_you_sure = nil
this.restart = true
this.soft_reset = false
if this.shutdown then
this.shutdown = false
2020-05-23 21:18:18 +02:00
end
2020-07-25 22:22:21 +02:00
p('[WARNING] Soft-reset is disabled! Server will restart from scenario to load new changes.')
2020-06-07 23:25:01 +02:00
return
end
2020-06-25 17:59:16 +02:00
elseif param == 'restartnow' then
this.reset_are_you_sure = nil
Server.start_scenario('Mountain_Fortress_v3')
return
2020-06-07 23:25:01 +02:00
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
2020-05-23 21:18:18 +02:00
end
2020-07-25 22:22:21 +02:00
p('[WARNING] Soft-reset is disabled! Server will shutdown. Most likely because of updates.')
2020-06-07 23:25:01 +02:00
return
2020-05-17 12:23:55 +02:00
end
2020-06-07 23:25:01 +02:00
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
2020-05-23 21:18:18 +02:00
end
end
)
commands.add_command(
'set_queue_speed',
'Usable only for admins - sets the queue speed of this map!',
function(cmd)
local p
local player = game.player
local param = tonumber(cmd.parameter)
2020-05-17 12:23:55 +02:00
2020-05-23 21:18:18 +02:00
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
end
if not param then
return
end
p('Queue speed set to: ' .. param)
Task.set_queue_speed(param)
else
p = log
p('Queue speed set to: ' .. param)
Task.set_queue_speed(param)
end
2020-05-17 12:23:55 +02:00
end
end
)
2020-05-23 21:18:18 +02:00
commands.add_command(
'get_queue_speed',
'Usable only for admins - gets the queue speed of this map!',
function()
local p
local player = game.player
if player then
if player ~= nil then
p = player.print
if not player.admin then
p("[ERROR] You're not admin!", Color.fail)
return
2020-05-17 12:23:55 +02:00
end
2020-05-23 21:18:18 +02:00
p(Task.get_queue_speed())
else
p = log
p(Task.get_queue_speed())
2020-05-17 12:23:55 +02:00
end
end
2020-05-23 21:18:18 +02:00
end
)