Skip to content

Commit

Permalink
fix the aerial caravan migration
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Nov 16, 2023
1 parent 7d6e7c7 commit baf9fd4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions migrations/2.1.10.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit baf9fd4

Please sign in to comment.