mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
implemented nuke control #8
This commit is contained in:
parent
57b86e43dc
commit
f8f5eb340a
@ -11,5 +11,5 @@ Event.register(-1, function()
|
||||
global.scenario.config.mapsettings.spiral_land_width = 70 -- width of land in spiral
|
||||
global.scenario.config.mapsettings.spiral_water_width = 70 -- width of water in spiral
|
||||
global.scenario.custom_functions = {}
|
||||
global.scenario.config.nuke_min_time_hours = 3 --how long a player must be on the server to be allowed to use the nuke
|
||||
end)
|
||||
|
||||
|
@ -13,6 +13,7 @@ require "train_station_names"
|
||||
require "score"
|
||||
require "map_layout"
|
||||
require "custom_commands"
|
||||
require "nuke_control"
|
||||
|
||||
|
||||
|
||||
|
18
nuke_control.lua
Normal file
18
nuke_control.lua
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
|
||||
|
||||
local function allowed_to_nuke(player)
|
||||
return player.admin or(player.online_time / 216000) > global.scenario.config.nuke_min_time_hours
|
||||
end
|
||||
|
||||
|
||||
local function ammo_changed(event)
|
||||
local player = game.players[event.player_index]
|
||||
if allowed_to_nuke(player) then return end
|
||||
local nukes = player.remove_item({name="atomic-bomb", count=1000})--.remove_item("atomic-bomb")
|
||||
if nukes > 0 then
|
||||
game.print(player.name .. " tried to use a nuke, but instead dropped it on his foot.")
|
||||
player.character.health = 0
|
||||
end
|
||||
end
|
||||
Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed)
|
Loading…
x
Reference in New Issue
Block a user