From baf9fd4bd0c7f36af1240459bc773bb60bdd4fe2 Mon Sep 17 00:00:00 2001 From: notnotmelon Date: Thu, 16 Nov 2023 11:48:55 -0600 Subject: [PATCH] fix the aerial caravan migration --- migrations/2.1.10.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/migrations/2.1.10.lua b/migrations/2.1.10.lua index 6a133728..8bb59101 100644 --- a/migrations/2.1.10.lua +++ b/migrations/2.1.10.lua @@ -3,7 +3,25 @@ local function exists_and_valid(v) return v and v.valid end if not global.caravans then return end local found = false local new = {} +local migrated = 0 + for _, caravan_data in pairs(global.caravans) do + if caravan_data.is_aerial and script.active_mods.pyalternativeenergy then + local entity = caravan_data.entity + local _, player = next(game.connected_players) + player = player or game.players[1] + entity.surface.create_entity{ + name = entity.name, + position = player.position, + force = entity.force_index, + player = player, + create_build_effect_smoke = false, + raise_built = true + } + if entity.valid then entity.destroy() end + migrated = migrated + 1 + end + if caravan_data.is_aerial or not caravan_data.unit_number or not caravan_data.entity @@ -21,4 +39,8 @@ end global.caravans = new if found then global.caravan_queue = nil +end + +if migrated > 0 then + game.print('Failed to migrate ' .. migrated .. ' aerial turbines into the new system. Since I\'m so nice, I teleported all of them to your position. Make sure to mine them and place them back so they actually work.') end \ No newline at end of file