From dfc9ae95aaf56ea76812d47ba6cc093bf25e2cee Mon Sep 17 00:00:00 2001 From: numzero Date: Wed, 17 Jul 2024 23:23:13 +0300 Subject: [PATCH] Migrate towers --- migrations/10-from-realistic-reactors.lua | 21 +++++++++++++++++++++ readme.md | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/migrations/10-from-realistic-reactors.lua b/migrations/10-from-realistic-reactors.lua index 875428b..de1336a 100644 --- a/migrations/10-from-realistic-reactors.lua +++ b/migrations/10-from-realistic-reactors.lua @@ -123,4 +123,25 @@ local function find_reactors() return reactors end +local function find_towers() + local towers = {} + for name, surface in pairs(game.surfaces) do + for _, entity in ipairs(surface.find_entities_filtered{name=TOWER_ENTITY_NAME}) do + local p = entity.position + local subs = get_subs(surface.find_entities({{p.x-1.5, p.y-1.5}, {p.x+1.5, p.y+1.5}}), { + entity = TOWER_ENTITY_NAME, + steam = STEAM_ENTITY_NAME, + }) + local tower = { + id = entity.unit_number, + entity = entity, + steam = subs.steam, + } + towers[tower.id] = tower + end + end + return towers +end + global.reactors = find_reactors() +global.towers = find_towers() diff --git a/readme.md b/readme.md index 755fbaa..0c9e90c 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ Forked from RealisticReactors due to bugs. #### Migration from RealisticReactors -Migration from RealisticReactors is partially supported. Reactors should work, however intermediate states (starting or stopping) may not work as expected. Cooling towers should work, though visuals may glitch. Other buildings weren’t tested yet. +Migration from RealisticReactors is partially supported. Reactors and cooling towers should work, however intermediate states (starting or stopping) may not work as expected. #### Original description