mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-07-17 01:32:31 +02:00
Implemented reactor alerts
This commit is contained in:
@ -4,7 +4,6 @@
|
|||||||
--a reactors loses 2 damage per second at 1000°C
|
--a reactors loses 2 damage per second at 1000°C
|
||||||
|
|
||||||
global.wastelands = {}
|
global.wastelands = {}
|
||||||
global.last_reactor_warning = 0
|
|
||||||
global.reactors = {}
|
global.reactors = {}
|
||||||
local wasteland_duration_seconds = 300
|
local wasteland_duration_seconds = 300
|
||||||
|
|
||||||
@ -53,16 +52,23 @@ function spawn_wasteland(surface, position)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function alert(reactor)
|
||||||
|
for _,p in pairs(game.players) do
|
||||||
|
p.add_custom_alert(reactor, {type="item", name="nuclear-reactor"}, string.format("Reactor at %s°C", reactor.temperature), true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function check_reactors()
|
local function check_reactors()
|
||||||
for _,surface in pairs(game.surfaces) do
|
for _,surface in pairs(game.surfaces) do
|
||||||
local last_reactor_warning = global.last_reactor_warning
|
|
||||||
for i,reactor in pairs(global.reactors) do
|
for i,reactor in pairs(global.reactors) do
|
||||||
if reactor.valid then
|
if reactor.valid then
|
||||||
if reactor.temperature > 800 and game.tick - global.last_reactor_warning > 900 then
|
if reactor.temperature > 800 then
|
||||||
game.print(string.format("Warning! Reactor at %s°C", math.floor(reactor.temperature)))
|
alert(reactor)
|
||||||
last_reactor_warning = game.tick
|
|
||||||
end
|
end
|
||||||
if reactor.temperature == 1000 then
|
if reactor.temperature == 1000 then
|
||||||
|
reactor.force = "enemy"
|
||||||
|
reactor.destructible = false
|
||||||
|
reactor.health = 0
|
||||||
reactor.surface.create_entity{name="atomic-rocket", position=reactor.position, target=reactor, speed=1}
|
reactor.surface.create_entity{name="atomic-rocket", position=reactor.position, target=reactor, speed=1}
|
||||||
spawn_wasteland(reactor.surface, reactor.position)
|
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}
|
global.wastelands[reactor.position.x .. "/" .. reactor.position.y] = {position = reactor.position, surface_id = reactor.surface.index, creation_time = game.tick}
|
||||||
|
Reference in New Issue
Block a user