1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

changes to reactor_meltdown

This commit is contained in:
grilledham 2018-05-16 12:00:12 +01:00
parent d27e29b9bc
commit 7d4d9366d6
2 changed files with 24 additions and 21 deletions

View File

@ -448,17 +448,6 @@ local function pool()
end
end
local function reactor_toggle()
if not game.player or game.player.admin then
global.reactors_enabled = not global.reactors_enabled
if global.reactors_enabled then
game.print("Reactor meltdown activated.")
else
game.print("Reactor meltdown deactivated.")
end
end
end
local old_add_command = commands.add_command
commands.add_command = function(name, desc, func)
old_add_command(name, desc, function(cmd)
@ -491,4 +480,3 @@ commands.add_command("zoom", "<number> Sets your zoom.", zoom)
commands.add_command("all-tech", "researches all technologies", function() if game.player and game.player.admin then game.player.force.research_all_technologies() end end)
commands.add_command("hax", "Toggles your hax", function() if game.player and game.player.admin then game.player.cheat_mode = not game.player.cheat_mode end end)
commands.add_command("pool", "Spawns a pool", pool)
commands.add_command("meltdown", "Toggles if reactors blow up", reactor_toggle)

View File

@ -5,22 +5,25 @@
local Event = require "utils.event"
global.reactors_enabled = false
global.wastelands = {}
global.reactors = {}
local wasteland_duration_seconds = 300
local function entity_destroyed(event)
if event.entity.name == "nuclear-reactor" then
local reactor = event.entity
if event.entity.temperature > 700 then
reactor.surface.create_entity{name="atomic-rocket", position=reactor.position, target=reactor, speed=1}
spawn_wasteland(reactor.surface, reactor.position)
global.wastelands[reactor.position.x .. "/" .. reactor.position.y] = {position = reactor.position, surface_id = reactor.surface.index, creation_time = game.tick}
end
if not global.reactors_enabled or not event.entity.valid or not event.entity.name == "nuclear-reactor" then
return
end
local reactor = event.entity
if reactor.temperature > 700 then
reactor.surface.create_entity{name="atomic-rocket", position=reactor.position, target=reactor, speed=1}
spawn_wasteland(reactor.surface, reactor.position)
global.wastelands[reactor.position.x .. "/" .. reactor.position.y] = {position = reactor.position, surface_id = reactor.surface.index, creation_time = game.tick}
end
end
function spawn_wasteland(surface, position)
local function spawn_wasteland(surface, position)
local positions = {
{0, 0},
{0, 12},
@ -102,7 +105,6 @@ local function check_wastelands()
end
end
global.reactors_enabled = true
local function on_tick()
if global.reactors_enabled then
check_wastelands()
@ -119,6 +121,19 @@ local function entity_build(event)
end
end
local function reactor_toggle()
if not game.player or game.player.admin then
global.reactors_enabled = not global.reactors_enabled
if global.reactors_enabled then
game.print("Reactor meltdown activated.")
else
game.print("Reactor meltdown deactivated.")
end
end
end
commands.add_command("meltdown", "Toggles if reactors blow up", reactor_toggle)
Event.on_nth_tick(60, on_tick)
Event.add(defines.events.on_player_mined_entity, entity_destroyed)
Event.add(defines.events.on_robot_mined_entity, entity_destroyed)