mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-30 04:30:58 +02:00
Updated crash site /restart command so that guests and regulars can call it when map is cleared
Updated crash site /restart command so that guests and regulars can call it when map is cleared - Only admin can abort, once the map is cleared. - Guests and Regular can both call /restart when all enemy units and structures are dead - Tested on S10 by running this command: /c local surface=game.player.surface for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do entity.destroy() end - Need to merge into develop to test on live server in case conditions at the end of the game are different - Thought about adding rocket launched condition but decided against it.
This commit is contained in:
parent
7b6b215584
commit
4b2510cc47
@ -1,10 +1,12 @@
|
||||
local Command = require 'utils.command'
|
||||
local Rank = require 'features.rank_system'
|
||||
local Task = require 'utils.task'
|
||||
local Token = require 'utils.token'
|
||||
local Server = require 'features.server'
|
||||
local Popup = require 'features.gui.popup'
|
||||
local Global = require 'utils.global'
|
||||
local Ranks = require 'resources.ranks'
|
||||
local Utils = require 'utils.core'
|
||||
|
||||
local server_player = {name = '<server>', print = print}
|
||||
|
||||
@ -55,6 +57,16 @@ local function restart(args, player)
|
||||
return
|
||||
end
|
||||
|
||||
if Rank.less_than(player.name, Ranks.admin) then
|
||||
-- Check enemy count
|
||||
local enemy_count = game.player.surface.count_entities_filtered{force= "enemy"}
|
||||
|
||||
if (enemy_count ~= 0) then
|
||||
game.player.print('All enemy spawners, worms, buildings, biters and spitters must be cleared for non-admin restart. Current enemy count: '.. enemy_count)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
global_data.restarting = true
|
||||
|
||||
double_print('#################-Attention-#################')
|
||||
@ -67,7 +79,7 @@ local function restart(args, player)
|
||||
end
|
||||
end
|
||||
print('Abort restart with /abort')
|
||||
|
||||
|
||||
Task.set_timeout_in_ticks(60, callback, {name = player.name, scenario_name = args.scenario_name, state = 10})
|
||||
end
|
||||
|
||||
@ -124,7 +136,7 @@ function Public.control(config)
|
||||
description = {'command_description.crash_site_restart'},
|
||||
arguments = {'scenario_name'},
|
||||
default_values = {scenario_name = default_name},
|
||||
required_rank = Ranks.admin,
|
||||
required_rank = Ranks.guest,
|
||||
allowed_by_server = true
|
||||
},
|
||||
restart
|
||||
|
Loading…
x
Reference in New Issue
Block a user