1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-02-13 13:49:35 +02:00

implemented deconstruction control

also fixed on_tick nil pointer
This commit is contained in:
Valansch 2017-07-23 04:39:02 +02:00
parent bad64b3301
commit 4596e56468
2 changed files with 20 additions and 9 deletions

View File

@ -1,6 +1,5 @@
local function allowed_to_nuke(player)
return player.admin or is_mod(player.name) or is_regular(player.name) or ((player.online_time / 216000) > global.scenario.config.nuke_min_time_hours)
end
@ -9,10 +8,24 @@ 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")
local nukes = player.remove_item({name="atomic-bomb", count=1000})
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
local function on_player_deconstructed_area(event)
local player = game.players[event.player_index]
if allowed_to_nuke(player) then return end
local nukes = player.remove_item({name="deconstruction-planner", count=1000})
game.print(player.name .. " tried to deconstruct something, but instead deconstructed himself.")
player.character.health = 0
for _,entity in pairs(game.players[event.player_index].surface.find_entities_filtered{area = event.area}) do
entity.cancel_deconstruction(game.players[event.player_index].force)
end
end
Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed)
Event.register(defines.events.on_player_deconstructed_area, on_player_deconstructed_area)

View File

@ -2,14 +2,12 @@ local function on_tick()
if game.tick % 60 == 0 then
poll_on_second()
walk_distance_on_second()
if game.tick % 120 == 0 then
pet_on_120_ticks()
if game.tick % 1200 == 0 then
player_list_on_12_seconds()
end
elseif game.tick % 180 == 0 then
if game.tick % 1200 == 0 then
player_list_on_12_seconds()
end
if game.tick % 180 == 0 then
fish_market_on_180_ticks()
end
end
end
end