This works by editing the control.lua inside the savefile.
The script is
Code: Select all
local function on_init()
global.silos = global.silos or find_silos()
global.ticks = global.ticks or 0
end
script.on_init(on_init)
local function on_creation(event)
global.silos = global.silos or find_silos()
local entity = event.created_entity
if entity.type == "rocket-silo" then
add_unique_value(global.silos, entity)
end
end
script.on_event(defines.events.on_built_entity, on_creation)
script.on_event(defines.events.on_robot_built_entity, on_creation)
local function on_destruction(event)
global.silos = global.silos or find_silos()
local entity = event.entity
if entity.type == "rocket-silo" then
remove_value(global.silos, entity)
end
end
script.on_event(defines.events.on_entity_died, on_destruction)
script.on_event(defines.events.on_robot_pre_mined, on_destruction)
script.on_event(defines.events.on_preplayer_mined_item, on_destruction)
local function on_tick()
global.silos = global.silos or find_silos()
global.ticks = (global.ticks or 0) + 1
if global.ticks >= 60 then
for k, silo in pairs(global.silos) do
if silo.valid then
if silo.get_item_count("satellite") > 0 then
silo.launch_rocket()
end
else
table.remove(global.silos, k)
end
end
global.ticks = 0
end
end
script.on_event(defines.events.on_tick, on_tick)
function add_unique_value(list, newValue)
for _, value in pairs(list) do
if value == newValue then
return
end
end
table.insert(list, newValue)
end
function remove_value(list, oldValue)
for i, value in pairs(list) do
if value == oldValue then
table.remove(list, i)
end
end
end
function find_silos()
local silos = {}
for _, surface in pairs(game.surfaces) do
for _, silo in pairs(surface.find_entities_filtered({type="rocket-silo"})) do
add_unique_value(silos, silo)
end
end
return silos
end
Currently I'm playing a single player game without mods to see how many rockets I can sent before 0.15 launches with this script in the savefile.