From c1a4429c8057e103b508a29dfdc8f519c6f1247c Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sat, 5 Jul 2025 22:24:55 +0200 Subject: [PATCH] Remove migrations --- .../migrations/Bio_Industries_0.17.02.lua | 20 - .../migrations/Bio_Industries_0.17.06.lua | 20 - .../migrations/Bio_Industries_0.17.11.lua | 22 - .../migrations/Bio_Industries_0.17.13.lua | 20 - .../migrations/Bio_Industries_0.17.19.json | 7 - .../migrations/Bio_Industries_0.17.22.lua | 38 - .../migrations/Bio_Industries_0.17.26.lua | 16 - .../migrations/Bio_Industries_0.17.31.lua | 16 - .../migrations/Bio_Industries_0.18.01.json | 143 ---- .../migrations/Bio_Industries_0.18.01.lua | 43 -- .../migrations/Bio_Industries_0.18.10.lua.bak | 82 -- .../migrations/Bio_Industries_0.18.11.lua.bak | 121 --- .../migrations/Bio_Industries_0.18.13.lua.bak | 135 ---- .../Bio_Industries_0.18.20_+_0.17.51.json | 6 - .../Bio_Industries_0.18.24_+_0.17.55.lua.bak | 122 --- .../Bio_Industries_0.18.27_+_0.17.58.lua | 45 -- .../migrations/Bio_Industries_0.18.29.json | 6 - .../migrations/Bio_Industries_0.18.29.lua.bak | 720 ------------------ .../Bio_Industries_0.18.31_+_1.01.01.json | 20 - .../Bio_Industries_0.18.31_+_1.01.01.lua | 12 - .../Bio_Industries_0.18.32_+_1.01.02.lua.bak | 29 - .../Bio_Industries_0.18.34_+_1.01.04.lua.bak | 122 --- .../Bio_Industries_0.18.35_+_1.01.05.json | 17 - .../Bio_Industries_0.18.35_+_1.01.05.lua | 39 - .../migrations/Bio_Industries_1.01.19.lua | 46 -- 25 files changed, 1867 deletions(-) delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.02.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.06.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.11.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.13.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.19.json delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.22.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.26.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.17.31.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.01.json delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.01.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.10.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.11.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.13.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.20_+_0.17.51.json delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.24_+_0.17.55.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.27_+_0.17.58.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.29.json delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.29.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.json delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.32_+_1.01.02.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.34_+_1.01.04.lua.bak delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.json delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.lua delete mode 100644 Bio_Industries_2/migrations/Bio_Industries_1.01.19.lua diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.02.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.02.lua deleted file mode 100644 index e17a203..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.02.lua +++ /dev/null @@ -1,20 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - if game.technology_prototypes["steel-processing"] and - technologies["steel-processing"].researched and - recipes["bi-stone-crusher"] then - - recipes["bi-stone-crusher"].enabled = true - recipes["bi-stone-crusher"].reload() - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.06.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.06.lua deleted file mode 100644 index 05ec2fd..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.06.lua +++ /dev/null @@ -1,20 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - if game.technology_prototypes["steel-processing"] and - technologies["steel-processing"].researched and - recipes["bi-crushed-stone-1"] then - - recipes["bi-crushed-stone-1"].enabled = true - recipes["bi-crushed-stone-1"].reload() - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.11.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.11.lua deleted file mode 100644 index 182836f..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.11.lua +++ /dev/null @@ -1,22 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - - - if game.technology_prototypes["bi-tech-bio-cannon"] and - technologies["bi-tech-bio-cannon"].researched and - recipes["bi-bio-cannon-proto-ammo"] then - - recipes["bi-bio-cannon-proto-ammo"].enabled = true - recipes["bi-bio-cannon-proto-ammo"].reload() - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.13.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.13.lua deleted file mode 100644 index fdef829..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.13.lua +++ /dev/null @@ -1,20 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - if game.technology_prototypes["electric-energy-accumulators"] and - technologies["electric-energy-accumulators"].researched then - if game.item_prototypes["bi-bio-accumulator"] then - recipes["bi-bio-accumulator"].enabled = true - recipes["bi-bio-accumulator"].reload() - end - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.19.json b/Bio_Industries_2/migrations/Bio_Industries_0.17.19.json deleted file mode 100644 index 788b532..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.19.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "item": - [ - ["bi-charcoal", "wood-charcoal"] - ] -} - diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.22.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.22.lua deleted file mode 100644 index d7fa812..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.22.lua +++ /dev/null @@ -1,38 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - if game.technology_prototypes["bi-tech-coal-processing-1"] then - if game.item_prototypes["wood-bricks"] then - if recipes["bi-wood-fuel-brick"] then - recipes["bi-wood-fuel-brick"].enabled = true - recipes["bi-wood-fuel-brick"].reload() - end - if recipes["bi-solid-fuel"] then - recipes["bi-solid-fuel"].enabled = true - recipes["bi-solid-fuel"].reload() - end - end - end - - if game.technology_prototypes["bi-tech-coal-processing-2"] and - recipes["bi-pellet-coke"] then - - recipes["bi-pellet-coke"].enabled = true - recipes["bi-pellet-coke"].reload() - end - - if game.technology_prototypes["bi-tech-bio-farming"] and - recipes["bi-woodpulp"] then - - recipes["bi-woodpulp"].enabled = true - recipes["bi-woodpulp"].reload() - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.26.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.26.lua deleted file mode 100644 index f60a44e..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.26.lua +++ /dev/null @@ -1,16 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - if game.technology_prototypes["bi-tech-coal-processing-3"] and recipes["bi-coke-coal"] then - recipes["bi-coke-coal"].enabled = true - recipes["bi-coke-coal"].reload() - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.17.31.lua b/Bio_Industries_2/migrations/Bio_Industries_0.17.31.lua deleted file mode 100644 index bd5a28d..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.17.31.lua +++ /dev/null @@ -1,16 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - ---~ game.reload_script() - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - if game.technology_prototypes["bi-tech-bio-farming"] and recipes["bi-wood-from-pulp"] then - recipes["bi-wood-from-pulp"].enabled = true - recipes["bi-wood-from-pulp"].reload() - end - - force.reset_recipes() - force.reset_technologies() -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.01.json b/Bio_Industries_2/migrations/Bio_Industries_0.18.01.json deleted file mode 100644 index 114e4a1..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.01.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "entity": - [ - ["bi-bioreactor", "bi-bio-reactor"], - ["Bio_Cannon_r", "Bio-Cannon-r"], - ["bi-big-wooden-pole", "bi-wooden-pole-big"], - ["bi-huge-wooden-pole", "bi-wooden-pole-huge"], - ["bi-large-wooden-chest", "bi-wooden-chest-large"], - ["bi-huge-wooden-chest", "bi-wooden-chest-huge"], - ["bi-large-wooden-chest", "bi-wooden-chest-large"], - ["bi-giga-wooden-chest", "bi-wooden-chest-giga"], - ["bi-solar-boiler-panel-2", "bi-solar-boiler-panel"], - ["bi-solar-boiler-2", "bi-solar-boiler"] - ], - - "item": - [ - ["bi-bioreactor", "bi-bio-reactor"], - ["bi-basic-dart-magazine", "bi-dart-magazine-basic"], - ["bi-enhanced-dart-magazine", "bi-dart-magazine-enhanced"], - ["bi-standard-dart-magazine", "bi-dart-magazine-standard"], - ["bi-poison-dart-magazine", "bi-dart-magazine-poison"], - ["bi-solar-boiler-2", "bi-solar-boiler"] - ], - - "recipe": - [ - ["bi_recipe_rail_wood", "bi-rail-wood"], - ["bi_recipe_rail_wood_to_concrete", "bi-rail-wood-to-concrete"], - ["bi_recipe_rail_wood_bridge", "bi-rail-wood-bridge"], - ["bi_rail_power", "bi-rail-power"], - ["bi_recipe_power_to_rail_pole", "bi-power-to-rail-pole"], - ["bi_recipe_basic_dart_magazine", "bi-dart-magazine-basic"], - ["bi_recipe_enhanced_dart_magazine", "bi-dart-magazine-enhanced"], - ["bi_recipe_standard_dart_magazine", "bi-dart-magazine-standard"], - ["bi_recipe_poison_dart_magazine", "bi-dart-magazine-poison"], - ["bi_recipe_bi_dart_rifle", "bi-dart-rifle"], - ["bi_recipe_big_wooden_pole", "bi-wooden-pole-big"], - ["bi_recipe_huge_wooden_pole", "bi-wooden-pole-huge"], - ["bi_recipe_bio_cannon", "bi-bio-cannon"], - ["bi_recipe_bio_cannon_basic_ammo", "bi-bio-cannon-basic-ammo"], - ["bi_recipe_bio_cannon_poison_ammo", "bi-bio-cannon-poison-ammo"], - ["bi_recipe_bio_cannon_proto_ammo", "bi-bio-cannon-proto-ammo"], - ["bi_recipe_boiler", "bi-bio-boiler"], - ["bi_recipe_dart_turret", "bi-dart-turret"], - ["bi_recipe_large_wooden_chest", "bi-wooden-chest-large"], - ["bi_recipe_huge_wooden_chest", "bi-wooden-chest-huge"], - ["bi_recipe_giga_wooden_chest", "bi-wooden-chest-giga"], - ["bi_recipe_production_science_pack", "bi-production-science-pack"], - ["bi_recipe_seed_bomb_advanced", "bi-seed-bomb-advanced"], - ["bi_recipe_seed_bomb_basic", "bi-seed-bomb-basic"], - ["bi_recipe_seed_bomb_standard", "bi-seed-bomb-standard"], - ["bi_recipe_wooden_fence", "bi-wooden-fence"], - ["bi_recipe_arboretum_r1", "bi-arboretum-r1"], - ["bi_recipe_arboretum_r2", "bi-arboretum-r2"], - ["bi_recipe_arboretum_r3", "bi-arboretum-r3"], - ["bi_recipe_arboretum_r4", "bi-arboretum-r4"], - ["bi_recipe_arboretum_r5", "bi-arboretum-r5"], - ["bi_recipe_arboretum", "bi-arboretum"], - ["bi_recipe_cellulose_1", "bi-cellulose-1"], - ["bi_recipe_cellulose_2", "bi-cellulose-2"], - ["bi_recipe_acid", "bi-acid"], - ["bi_recipe_accumulator", "bi-bio-accumulator"], - ["bi_recipe_adv_fertiliser_1", "bi-adv-fertiliser-1"], - ["bi_recipe_adv_fertiliser_2", "bi-adv-fertiliser-2"], - ["bi_recipe_ash_1", "bi-ash-1"], - ["bi_recipe_ash_2", "bi-ash-2"], - ["bi_recipe_battery", "bi-battery"], - ["bi_recipe_bio_farm", "bi-bio-farm"], - ["bi_recipe_bio_garden", "bi-bio-garden"], - ["bi_recipe_bio_solar_farm", "bi-bio-solar-farm"], - ["bi_recipe_biomass_1", "bi-biomass-1"], - ["bi_recipe_biomass_2", "bi-biomass-2"], - ["bi_recipe_biomass_3", "bi-biomass-3"], - ["bi_recipe_biomass_conversion_1", "bi-biomass-conversion-1"], - ["bi_recipe_biomass_conversion_2", "bi-biomass-conversion-2"], - ["bi_recipe_biomass_conversion_3", "bi-biomass-conversion-3"], - ["bi_recipe_biomass_conversion_4", "bi-biomass-conversion-4"], - ["bi_recipe_burner_inserter_disassemble", "bi-burner-inserter-disassemble"], - ["bi_recipe_burner_mining_drill_disassemble", "bi-burner-mining-drill-disassemble"], - ["bi_recipe_long_handed_inserter_disassemble", "bi-long-handed-inserter-disassemble"], - ["bi_recipe_steel_furnace_disassemble", "bi-steel-furnace-disassemble"], - ["bi_recipe_stone_furnace_disassemble", "bi-stone-furnace-disassemble"], - ["bi_recipe_charcoal_2", "bi-charcoal-2"], - ["bi_recipe_charcoal", "bi-charcoal-1"], - ["bi_recipe_clean_air_1", "bi-purified-air-1"], - ["bi_recipe_clean_air_2", "bi-purified-air-2"], - ["bi_recipe_coal_2", "bi-coal-2"], - ["bi_recipe_coal", "bi-coal-1"], - ["bi_recipe_coke_coal", "bi-coke-coal"], - ["bi_recipe_crushed_stone", "bi-crushed-stone-1"], - ["bi_recipe_fertiliser_1", "bi-fertiliser-1"], - ["bi_recipe_fertiliser_2", "bi-fertiliser-2"], - ["bi_recipe_greenhouse", "bi-bio-greenhouse"], - ["bi_recipe_huge_substation", "bi-large-substation"], - ["bi_recipe_liquid_air", "bi-liquid-air"], - ["bi_recipe_logs_mk1", "bi-logs-1"], - ["bi_recipe_logs_mk2", "bi-logs-2"], - ["bi_recipe_logs_mk3", "bi-logs-3"], - ["bi_recipe_logs_mk4", "bi-logs-4"], - ["bi_recipe_nitrogen", "bi-nitrogen"], - ["bi_recipe_plastic_1", "bi-plastic-1"], - ["bi_recipe_plastic_2", "bi-plastic-2"], - ["bi_recipe_seed_1", "bi-seed-1"], - ["bi_recipe_seed_2", "bi-seed-2"], - ["bi_recipe_seed_3", "bi-seed-3"], - ["bi_recipe_seed_4", "bi-seed-4"], - ["bi_recipe_seedling_mk1", "bi-seedling-1"], - ["bi_recipe_seedling_mk2", "bi-seedling-2"], - ["bi_recipe_seedling_mk3", "bi-seedling-3"], - ["bi_recipe_seedling_mk4", "bi-seedling-4"], - ["bi_recipe_solar_boiler_panel", "bi-solar-boiler-panel"], - ["bi_recipe_solar_mat", "bi-solar-mat"], - ["bi_recipe_sulfur_angels", "bi-sulfur-angels"], - ["bi_recipe_sulfur", "bi-sulfur"], - ["bi_recipe_woodpulp", "bi-woodpulp"], - ["bi_recipe_wood_from_pulp", "bi-wood-from-pulp"], - ["bi_recipe_pellete_coal_2", "bi-pellete-coal-2"], - ["bi_recipe_bioreactor", "bi-bio-reactor"], - ["bi_recipe_mineralized_sulfuric_waste", "bi-mineralized-sulfuric-waste"], - ["bi_recipe_slag_slurry", "bi-slag-slurry"], - ["bi_recipe_resin_wood", "bi-resin-wood"], - ["bi_recipe_resin_pulp", "bi-resin-pulp"], - ["bi_recipe_press_wood", "bi-press-wood"], - ["bi_recipe_stone_brick", "bi-stone-brick"], - ["bi_recipe_wood_fuel_brick", "bi-wood-fuel-brick"], - ["bi_recipe_solid_fuel", "bi-solid-fuel"], - ["bi_recipe_pellet_coke", "bi-pellet-coke"], - ["bi_recipe_wood_pipe", "bi-wood-pipe"], - ["bi_recipe_pipe_to_ground_wood", "bi-wood-pipe-to-ground"], - ["bi_recipe_cokery", "bi-cokery"], - ["bi_recipe_stone_crusher", "bi-stone-crusher"] - ], - - "technology": - [ - ["bi_tech_advanced_biotechnology", "bi-tech-advanced-biotechnology"], - ["bi_tech_bio_cannon", "bi-tech-bio-cannon"], - ["bi_tech_bio_farming", "bi-tech-bio-farming"], - ["bi_tech_fertiliser", "bi-tech-fertiliser"], - ["bi_tech_organic_plastic", "bi-tech-organic-plastic"] - ] -} diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.01.lua b/Bio_Industries_2/migrations/Bio_Industries_0.18.01.lua deleted file mode 100644 index 2dc639b..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.01.lua +++ /dev/null @@ -1,43 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') ---~ game.reload_script() - - -for index, force in pairs(game.forces) do - local technologies = force.technologies - local recipes = force.recipes - - for _, tech in ipairs({"bi-tech-coal-processing-2", "bi-tech-coal-processing-3"}) do - -- Technology exists and has already been researched -BioInd.writeDebug("Checking tech: %s for force %s (Researched: %s)", {tech, force and force.name or "nil", technologies[tech] and technologies[tech].researched or "nil"}) - - if game.technology_prototypes[tech] and technologies[tech].researched then - -- Check if all prerequisite technologies have been researched - local all_prereqs = true - for pname, ptech in pairs(technologies[tech].prerequisites) do - BioInd.writeDebug("pname: %s", {pname}) - BioInd.writeDebug("ptech: %s", {ptech}) - if not ptech.researched then - all_prereqs = false - break - end - end - - -- If not all prerequisite technologies have been researched, ... - if not all_prereqs then - game.print({"", "Not all prerequisite technologies for ", {"technology-name." .. tech}, " have been researched!"}) - -- reset all unlocked recipes and - for _, effect in pairs(technologies[tech].effects) do - if effect.type == "unlock-recipe" then - game.print({"", "Disabling recipe \"", {"recipe-name." .. effect.recipe}, "\""}) - recipes[effect.recipe].enabled = false - recipes[effect.recipe].reload() - end - end - -- unresearch the technology - game.print({"", "Disabling technology \"", {"technology-name." .. tech}, "\"" }) - technologies[tech].researched = false - technologies[tech].reload() - end - end - end -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.10.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.10.lua.bak deleted file mode 100644 index 54f5d6b..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.10.lua.bak +++ /dev/null @@ -1,82 +0,0 @@ -local BioInd = require('__Bio_Industries__/common')('Bio_Industries') ------------------------------------------------------------------------------------- --- Remove left over radars and hidden entities left after terraformer (arboretum) --- has been moved. ------------------------------------------------------------------------------------- - --- Function to remove entities -local function remove_entity(surface, data) - local name = data[1] - local type = data[2] - local desc = data[3] - local name_in_table = data[4] or type -- Needed for "electric-pole", which is stored as "pole" in the table - - local count = 0 - - -- Look for entity on surface - local surface_entities = surface.find_entities_filtered{ - name = name, - type = type, - } - --~ BioInd.writeDebug("Found " .. tostring(#surface_entities) .. " " .. desc .. "s.") - - -- Check against entities in list - for index, entity in pairs(surface_entities) do - BioInd.writeDebug("%g: Looking for %s: %s.", {index, desc, entity.unit_number}) - - local match = false - for _a, arboretum in pairs(global.bi_arboretum_table or {}) do - --~ BioInd.writeDebug("arboretum: %s", {arboretum}) - if entity == arboretum[name_in_table] then - BioInd.writeDebug("The %s (%g) belongs to arboretum/terraformer %g!", {desc, entity.unit_number, _a}) - match = trueentity.unit_number - break - end - end - - -- Remove entity from surface if it has no match in arboretum/terraformer list - if not match then - log("Removing " .. desc .. " " .. entity.unit_number .. ".") - count = count + 1 - entity.destroy() - end - end - log("Removed " .. tostring(count) .. " " .. desc .. "s (terraformer remnants) from " .. surface.name .. ".") - game.print("[Bio Industries] Removed " .. tostring(count) .. " " .. desc .. "s (terraformer remnants) from " .. surface.name .. ".") -end - --- Clean up global list of arboretums -if global.bi_arboretum_table then - - BioInd.writeDebug("Remove invalid arboretums/terraformers from list:") - local count = 0 - for index, arboretum in pairs(global.bi_arboretum_table) do - local entity = arboretum.inventory - - BioInd.writeDebug("Arboretum %g is valid: %s", {index, entity and entity.valid}) - if not entity.valid then - global.bi_arboretum_table[index] = nil - count = count + 1 - log("Removed arboretum/terraformer " .. tostring(index) .. " from global list.") - end - end - log("Removed " .. tostring(count) .. " non-existing terraformers from global list.") - game.print("[Bio Industries] Removed " .. tostring(count) .. " non-existing terraformers from global list.") - - ------------------------------------------------------------------------------------ - -- Check for left-over entities from moved/removed arboretums/terraformers - for index, surface in pairs(game.surfaces) do - BioInd.writeDebug("Looking for left-over hidden entities from moved/removed terraformers on %s.", {surface.name}) - - for _, entity in pairs({ - {"bi-arboretum-hidden-radar", "radar", "radar"}, - {"bi-hidden-power-pole", "electric-pole", "hidden power pole", "pole"}, - {"bi-bio-farm-light", "lamp", "hidden lamp"} - }) do - - remove_entity(surface, entity) - end - - end - BioInd.writeDebug("Done.") -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.11.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.11.lua.bak deleted file mode 100644 index 9b4b710..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.11.lua.bak +++ /dev/null @@ -1,121 +0,0 @@ -local BioInd = require('common')('Bio_Industries') ------------------------------------------------------------------------------------- --- Restore hidden power poles and hidden lamps accidentally removed in the --- previous version. ------------------------------------------------------------------------------------- - -local pole_name = "bi-hidden-power-pole" -local lamp_name = "bi-bio-farm-light" - -local pole_count = 0 -local lamp_count = 0 - --- Restoring hidden power pole for solar boilers -for index, solar_boiler in pairs(global.bi_solar_boiler_table) do - -- Remove invalid solar boilers from list - if not solar_boiler.base.valid then - BioInd.writeDebug("Removing invalid solar boiler " .. tostring(index) .. " from global list.") - if solar_boiler.boiler.valid then - solar_boiler.boiler.destroy() - end - if solar_boiler.pole.valid then - solar_boiler.pole.destroy() - end - global.bi_solar_boiler_table = nil - - -- Restore hidden power pole if necessary - elseif not solar_boiler.pole.valid then - BioInd.writeDebug("Creating new hidden power pole for solar boiler " .. tostring(index) .. ".") - local new_pole = solar_boiler.base.surface.create_entity({ - name = pole_name, - position = solar_boiler.base.position, - direction = solar_boiler.base.direction, - force = solar_boiler.base.force - }) - global.bi_solar_boiler_table[index].pole = new_pole - pole_count = pole_count + 1 - end -end -log("Restored " .. tostring(pole_count) .. " hidden power poles for solar boilers.") -game.print("[Bio Industries] Restored " .. tostring(pole_count) .. " hidden power poles for solar boilers.") - - --- Restoring hidden power pole for solar farms -pole_count = 0 - -for index, solar_farm in pairs(global.bi_solar_farm_table) do - -- Remove invalid solar boilers from list - if not solar_farm.base.valid then - BioInd.writeDebug("Removing invalid solar farm " .. tostring(index) .. " from global list.") - if solar_farm.pole.valid then - solar_farm.pole.destroy() - end - global.bi_solar_farm_table = nil - - -- Restore hidden power pole if necessary - elseif not solar_farm.pole.valid then - BioInd.writeDebug("Creating new hidden power pole for solar farm " .. tostring(index) .. ".") - local new_pole = solar_farm.base.surface.create_entity({ - name = pole_name, - position = solar_farm.base.position, - direction = solar_farm.base.direction, - force = solar_farm.base.force - }) - global.bi_solar_farm_table[index].pole = new_pole - pole_count = pole_count + 1 - end -end -log("Restored " .. tostring(pole_count) .. " hidden power poles for solar farms.") -game.print("[Bio Industries] Restored " .. tostring(pole_count) .. " hidden power poles for solar farms.") - - --- Restoring hidden power pole and hidden lamps for bio farms -pole_count = 0 - -for index, bio_farm in pairs(global.bi_bio_farm_table) do - -- Remove invalid solar boilers from list - if not bio_farm.base.valid then - BioInd.writeDebug("Removing invalid solar farm " .. tostring(index) .. " from global list.") - if bio_farm.pole.valid then - bio_farm.pole.destroy() - end - if bio_farm.panel.valid then - bio_farm.panel.destroy() - end - if bio_farm.lamp.valid then - bio_farm.lamp.destroy() - end - global.bi_bio_farm_table = nil - - -- Restore hidden entities if necessary - else - -- Restore hidden power pole - if not bio_farm.pole.valid then - BioInd.writeDebug("Creating new hidden power pole for solar farm " .. tostring(index) .. ".") - local new_pole = bio_farm.base.surface.create_entity({ - name = pole_name, - position = bio_farm.base.position, - direction = bio_farm.base.direction, - force = bio_farm.base.force - }) - global.bi_bio_farm_table[index].pole = new_pole - pole_count = pole_count + 1 - end - -- Restore hidden lamp - if not bio_farm.lamp.valid then - BioInd.writeDebug("Creating new hidden lamp for solar farm " .. tostring(index) .. ".") - local new_lamp = bio_farm.base.surface.create_entity({ - name = lamp_name, - position = bio_farm.base.position, - force = bio_farm.base.force - }) - - global.bi_bio_farm_table[index].lamp = new_lamp - lamp_count = lamp_count + 1 - end - end -end -log("Restored " .. tostring(pole_count) .. " hidden power poles and " .. tostring(lamp_count) .. - " hidden lamps for bio farms.") -game.print("[Bio Industries] Restored " .. tostring(pole_count) .. " hidden power poles and " .. tostring(lamp_count) .. - " hidden lamps for bio farms.") diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.13.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.13.lua.bak deleted file mode 100644 index 4c97bfa..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.13.lua.bak +++ /dev/null @@ -1,135 +0,0 @@ -local BioInd = require('__Bio_Industries__/common')('Bio_Industries') -log("Entered fixed migration script!") ------------------------------------------------------------------------------------- --- In 0.18.11, loading a saved game could have resulted in a crash because a --- complete table (instead of individual entries) was removed. However, if --- the complete table *was* deleted, the game *must* have crashed and the original --- tables couldn't have been overwritten in a new saved game. So, we can presume --- all tables still exist in the state of pre 0.18.11 and just run the (fixed) --- migration script from 0.18.11 again. ------------------------------------------------------------------------------------- - -local pole_name = "bi-hidden-power-pole" -local lamp_name = "bi-bio-farm-light" - -local pole_count = 0 -local lamp_count = 0 - --- Restoring hidden power pole for solar boilers -if global.bi_solar_boiler_table then - for index, solar_boiler in pairs(global.bi_solar_boiler_table) do - -- Remove invalid solar boilers from list - if not solar_boiler.base.valid then - BioInd.writeDebug("Removing invalid solar boiler %g from global list.", {index}) - if solar_boiler.boiler.valid then - solar_boiler.boiler.destroy() - end - if solar_boiler.pole.valid then - solar_boiler.pole.destroy() - end - global.bi_solar_boiler_table[index] = nil - - -- Restore hidden power pole if necessary - elseif not solar_boiler.pole.valid then - BioInd.writeDebug("Creating new hidden power pole for solar boiler %g.", {index}) - global.bi_solar_boiler_table[index].pole = solar_boiler.base.surface.create_entity({ - name = pole_name, - position = solar_boiler.base.position, - direction = solar_boiler.base.direction, - force = solar_boiler.base.force - }) - pole_count = pole_count + 1 - end - end - if pole_count > 0 then - log("Restored " .. tostring(pole_count) .. " hidden power poles for solar boilers.") - game.print("[Bio Industries] Restored " .. tostring(pole_count) .. " hidden power poles for solar boilers.") - end -end - --- Restoring hidden power pole for solar farms -if global.bi_solar_farm_table then - pole_count = 0 - - for index, solar_farm in pairs(global.bi_solar_farm_table) do - -- Remove invalid solar boilers from list - if not solar_farm.base.valid then - BioInd.writeDebug("Removing invalid solar farm %g from global list.", {index}) - if solar_farm.pole.valid then - solar_farm.pole.destroy() - end - global.bi_solar_farm_table[index] = nil - - -- Restore hidden power pole if necessary - elseif not solar_farm.pole.valid then - BioInd.writeDebug("Creating new hidden power pole for solar farm %g.", {index}) - --~ local new_pole = solar_farm.base.surface.create_entity({ - global.bi_solar_farm_table[index].pole = solar_farm.base.surface.create_entity({ - name = pole_name, - position = solar_farm.base.position, - direction = solar_farm.base.direction, - force = solar_farm.base.force - }) - pole_count = pole_count + 1 - end - end - if pole_count > 0 then - log("Restored " .. tostring(pole_count) .. " hidden power poles for solar farms.") - game.print("[Bio Industries] Restored " .. tostring(pole_count) .. " hidden power poles for solar farms.") - end -end - - --- Restoring hidden power pole and hidden lamps for bio farms -if global.bi_bio_farm_table then - pole_count = 0 - - for index, bio_farm in pairs(global.bi_bio_farm_table) do - -- Remove invalid solar boilers from list - if not bio_farm.base.valid then - BioInd.writeDebug("Removing invalid solar farm %g from global list.", {index}) - if bio_farm.pole.valid then - bio_farm.pole.destroy() - end - if bio_farm.panel.valid then - bio_farm.panel.destroy() - end - if bio_farm.lamp.valid then - bio_farm.lamp.destroy() - end - global.bi_bio_farm_table[index] = nil - - -- Restore hidden entities if necessary - else - -- Restore hidden power pole - if not bio_farm.pole.valid then - BioInd.writeDebug("Creating new hidden power pole for solar farm %g.", {index}) - --~ local new_pole = bio_farm.base.surface.create_entity({ - global.bi_bio_farm_table[index].pole = bio_farm.base.surface.create_entity({ - name = pole_name, - position = bio_farm.base.position, - direction = bio_farm.base.direction, - force = bio_farm.base.force - }) - pole_count = pole_count + 1 - end - -- Restore hidden lamp - if not bio_farm.lamp.valid then - BioInd.writeDebug("Creating new hidden lamp for solar farm %g.", {index}) - --~ local new_lamp = bio_farm.base.surface.create_entity({ - global.bi_bio_farm_table[index].lamp = bio_farm.base.surface.create_entity({ - name = lamp_name, - position = bio_farm.base.position, - force = bio_farm.base.force - }) - lamp_count = lamp_count + 1 - end - end - end - if pole_count > 0 or lamp_count > 0 then - log("Restored " .. tostring(pole_count) .. " hidden power poles and " .. tostring(lamp_count) .. - " hidden lamps for bio farms.") - game.print("[Bio Industries] Restored " .. tostring(pole_count) .. " hidden power poles and " .. - tostring(lamp_count) .. " hidden lamps for bio farms.") - end -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.20_+_0.17.51.json b/Bio_Industries_2/migrations/Bio_Industries_0.18.20_+_0.17.51.json deleted file mode 100644 index 2b67b38..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.20_+_0.17.51.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recipe": - [ - ["bi-basic-petroleum-gas-processing", "bi-basic-gas-processing"] - ] -} diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.24_+_0.17.55.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.24_+_0.17.55.lua.bak deleted file mode 100644 index faa4fdb..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.24_+_0.17.55.lua.bak +++ /dev/null @@ -1,122 +0,0 @@ -local BioInd = require('__Bio_Industries__/common')('Bio_Industries') ------------------------------------------------------------------------------------- --- This version uses a different algorithm to wiring the powered rails. Only --- Rail-to-power connectors and poles on rails connected to (not crossing!) a newly --- placed track will be connected with each other. ------------------------------------------------------------------------------------- - -BioInd.writeDebug("Entered migration script 0.18.24+0.17.55") - --- Look for Rail-to-power connectors on all surfaces -for s, surface in pairs(game.surfaces) do - local connectors = surface.find_entities_filtered{name = "bi-power-to-rail-pole"} ---log("Looking for rail-to-power connectors on surface " .. s) - for _, connector in ipairs(connectors) do - -- Find connections to powered rails - local neighbours = connector.neighbours["copper"] ---log("neighbours of connector " .. connector.unit_number .. ": " .. serpent.block(neighbours)) - for p, pole in pairs(neighbours) do - -- Disconnect hidden power-rail poles from connector - if pole.name == "bi-power-rail-hidden-pole" then - connector.disconnect_neighbour(pole) ---log("Disconnected " .. pole.name .. " " .. pole.unit_number) - end - end - end -end - - -log("Done -- looking for hidden poles now!") --- Disconnect all hidden rail poles -for r, rail in pairs(global.bi_power_rail_table) do - -- Rail is still valid - if rail.base and rail.base.valid then ---log(tostring(r) .. ": rail.base.valid: " .. tostring(rail.base.valid)) - -- Disconnect pole if it's valid! - if rail.pole and rail.pole.valid then - rail.pole.disconnect_neighbour() - BioInd.writeDebug("Disconnected pole number %g", {rail.pole.unit_number}) ---log("Disconnected pole number " .. rail.pole.unit_number) - -- Place a new pole if we don't have one yet. - else - -- Create Hidden Power Pole - local track = rail.base - local new_pole = track.surface.create_entity({ - name = "bi-power-rail-hidden-pole", - position = track.position, - force = track.force - }) - new_pole.minable = false - new_pole.destructible = false - new_pole.disconnect_neighbour() - - global.bi_power_rail_table[r].pole = new_pole - BioInd.writeDebug("Created new pole %g on %s.", {new_pole.unit_number, track.name, track.unit_number}) - end - -- Rail doesn't exist anymore - elseif not rail.base.valid then ---log(tostring(r) .. ": rail.base.valid: " .. tostring(rail.base.valid)) - -- Check the pole! - if rail.pole and rail.pole.valid then - BioInd.writeDebug("Rail %g doesn't exist anymore: Removing pole %g from surface %s.", {r, rail.pole.unit_number, rail.pole.surface.name, rail.pole.surface.name}) - rail.pole.destroy() - end - - -- Remove track from table! - global.bi_power_rail_table[r] = nil - BioInd.writeDebug("Removed powered rail %g from table.", {r}) - end -end - --- Rewire hidden rail poles -for r, rail in pairs(global.bi_power_rail_table) do -BioInd.writeDebug("Disconnected pole number %g", {rail.pole.unit_number}) ---log("Disconnected pole number " .. rail.pole.unit_number) - local rail_track = rail.base - local rail_pole = rail.pole - -- Look for connecting rails at front and back of the new rail - for s, side in ipairs( {"front", "back"} ) do -BioInd.writeDebug("Looking for rails at %s", {side}) ---log("Looking for rails at " .. side) - local neighbour - -- Look in all three directions - for d, direction in ipairs( {"left", "straight", "right"} ) do -BioInd.writeDebug("Looking for rails in %s direction", {direction}) ---log("Looking for rails in " .. direction .. " direction") - neighbour = rail_track.get_connected_rail{ - rail_direction = defines.rail_direction[side], - rail_connection_direction = defines.rail_connection_direction[direction] - } -BioInd.writeDebug("Rail %s of %s (%s): (%s)", {direction, rail_track.name, rail_track.unit_number,neighbour and neighbour.name or "nil", neighbour and neighbour.unit_number or "nil"}) ---log("Rail " .. direction .. " of " .. - --~ rail_track.name .. " (" .. rail_track.unit_number .. "): " .. - --~ serpent.line(neighbour and neighbour.name) .. - --~ " (" .. serpent.line(neighbour and neighbour.unit_number) ..")") - - -- Only make a connection if found rail is a powered rail - -- (We'll know it's the right type if we find it in our table!) - neighbour = neighbour and neighbour.valid and global.bi_power_rail_table[neighbour.unit_number] - if neighbour then - rail_pole.connect_neighbour(neighbour.pole) -BioInd.writeDebug("Connected poles!") ---log("Connected poles!") - end - end - - -- Look for Power-rail connectors - local connector = rail_track.surface.find_entities_filtered{ - position = rail_track.position, - radius = BioInd.POWER_TO_RAIL_WIRE_DISTANCE, -- maximum_wire_distance of Power-to-rail-connectors - name = "bi-power-to-rail-pole" - } - - -- Connect to first Power-rail connector we've found - if connector and table_size(connector) > 0 then - rail_pole.connect_neighbour(connector[1]) -BioInd.writeDebug("Connected %s (%g) to %s (%g)", {rail_pole.name, rail_pole.unit_number, connector[1].name, connector[1].unit_number}) - end - end -end - -BioInd.writeDebug("End of migration script 0.18.24+0.17.55") ---log("End of migration script 0.18.24+0.17.55") diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.27_+_0.17.58.lua b/Bio_Industries_2/migrations/Bio_Industries_0.18.27_+_0.17.58.lua deleted file mode 100644 index 4142e24..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.27_+_0.17.58.lua +++ /dev/null @@ -1,45 +0,0 @@ ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') ------------------------------------------------------------------------------------- --- For some reason, the recipe for bi-biomass-2 was more advanced than the recipe --- for bi-biomass-3. This worked because we changed their order whereever they've --- been used, but it wasn't intuitive and caused confusion. --- The recipes have been renamed in 0.17.58/0.18.27, now we need to make sure that --- the recipes in bio-reactors making bio-mass are exchanged as well! ------------------------------------------------------------------------------------- - -BioInd.writeDebug("Entered migration script 0.18.27+0.17.58") - - --- Look for bio-reactors on all surfaces -local reactors, recipe - -for s, surface in pairs(game.surfaces) do - reactors = surface.find_entities_filtered{ - type = "assembling-machine", - name = "bi-bio-reactor" - } - BioInd.writeDebug("Found %g bio-reactors on surface \"%s\".", - {#reactors, surface.name}) - - -- Get recipe of reactors - for r, reactor in ipairs(reactors) do - recipe = reactor.get_recipe() - recipe = recipe and recipe.name or "" - BioInd.writeDebug("Reactor %g has recipe \"%s\".", - {reactor.unit_number, recipe}) - - -- Exchange "bi-biomass-2" against "bi-biomass-3" - if recipe == "bi-biomass-2" then - reactor.set_recipe("bi-biomass-3") - BioInd.writeDebug("Set recipe to %s.", {reactor.get_recipe().name}) - - -- Exchange "bi-biomass-3" against "bi-biomass-2" - elseif recipe == "bi-biomass-3" then - reactor.set_recipe("bi-biomass-2") - BioInd.writeDebug("Set recipe to %s.", {reactor.get_recipe().name}) - end - end - -end - -BioInd.writeDebug("End of migration script 0.18.27+0.17.58") diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.29.json b/Bio_Industries_2/migrations/Bio_Industries_0.18.29.json deleted file mode 100644 index f49ba27..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.29.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recipe": - [ - ["bi-pellete-coal-2", "bi-pellet-coke-2"] - ] -} diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.29.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.29.lua.bak deleted file mode 100644 index b5c5f7a..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.29.lua.bak +++ /dev/null @@ -1,720 +0,0 @@ ------------------------------------------------------------------------------------- --- We didn't react to script_raised_revive before, so mods like Construction Drones --- that filled in ghosts would just place the base entities, and not add the hidden --- entities. Even worse: the base entities wouldn't be added to our lists! So, let's --- rebuild everything once again! ------------------------------------------------------------------------------------- - -local BioInd = require('__Bio_Industries__/common')('Bio_Industries') -local cnt = 0 - - -game.print("Warning: The migration may run for a long time, depending on how many entities there are to migrate! Please be patient and wait until it's finished!") - --- Removes the hidden entities at the position of a base entity -local created_entities = {} -local function remove_entities(base, names) - local entities = base and base.surface.find_entities_filtered{ - position = base.position, - name = names, - } -if entities and next(entities) then -BioInd.show("base.unit_number", base.unit_number) -BioInd.show("Found entities", table_size(entities)) -end - - for e, entity in ipairs(entities or {}) do ---~ BioInd.show("entity.unit_number", entity.unit_number) - if not created_entities[entity.unit_number] then - entity.destroy() - end - end -end - - --- Removes the hidden entities stored with a base entity -local function remove_stored_entities(base, names) - for e, entity in ipairs(names or {}) do - if base[entity] and base[entity].valid then - base[entity].destroy() - end - end -end - - --- Make hidden entities unminable and indestructible -local function make_unminable(entities) - for e, entity in ipairs(entities or {}) do - if entity.valid then - entity.minable = false - entity.destructible = false - end - end -end - - --- Recreate hidden entities -local function recreate_entities(g_table, base_entity, hidden_entity_names, ...) -BioInd.show("#g_table", table_size(g_table)) -BioInd.show("hidden_entity_names", hidden_entity_names) - - if not (g_table and type(g_table) == "table") then - error(string.format("%s is not a valid table!", g_table)) - elseif not (base_entity and type(base_entity) == "table" and base_entity.valid) then - error(string.format("%s is not a valid base entity!", base_entity)) - elseif not ( - hidden_entity_names and type(hidden_entity_names) == "table" and next(hidden_entity_names) - ) then - error(string.format("%s is not a valid array of hidden-entity names!", hidden_entity_names)) - end - - local entity - - -- Initialize entry in global table - g_table[base_entity.unit_number] = {} - g_table[base_entity.unit_number].base = base_entity - - -- Create hidden entities - for key, name in pairs(hidden_entity_names) do - entity = base_entity.surface.create_entity({ - name = name, - position = base_entity.position, - force = base_entity.force - }) - - -- Make hidden entity unminable/undestructible - make_unminable({entity}) - - -- Add hidden entity to global table - g_table[base_entity.unit_number][key] = entity - - -- Add to temporary table of recreated hidden entities - created_entities[entity.unit_number] = true - end - - -- Add optional values to global table - for k, v in pairs(... or {}) do - g_table[base_entity.unit_number][k] = v - end -BioInd.show("g_table[base.unit_number]", g_table[base_entity.unit_number]) -end - - --- Remove all common hidden power poles and hidden power rail poles -do - local entities - for s, surface in pairs(game.surfaces) do - entities = surface.find_entities_filtered({ - name = {"bi-hidden-power-pole", "bi-power-rail-hidden-pole"} - }) - for e, entity in pairs(entities) do - entity.destroy() - cnt = cnt + 1 - end - end - BioInd.writeDebug("Removed %s hidden poles (bi-hidden-power-pole, bi-power-rail-hidden-pole)", cnt) -end - -local base, boiler, lamp, pole, panel, radar, connectors -local base_name, boiler_name, lamp_name, pole_name, radar_name, panel_name, overlay_name - - - ------------------------------------------------------------------------------------- --- Bio Farm -- ------------------------------------------------------------------------------------- - --- Empty old list -for b, bio_farm in pairs(global.bi_bio_farm_table or {}) do - -- Remove hidden entities from bio_farms in our table - --~ for e, entity in ipairs({"pole", "panel", "lamp"}) do - --~ if bio_farm[entity] and bio_farm[entity].valid then - --~ bio_farm[entity].destroy() - --~ end - --~ end - remove_stored_entities(bio_farm, {"pole", "panel", "lamp"}) - -- Remove entry from table - global.bi_bio_farm_table[b] = nil - - cnt = cnt + 1 -end -BioInd.writeDebug("Removed hidden entities from %s Bio-farms.", {cnt}) - --- Generate new list ---~ local bio_farms, pole, panel, lamp -local bio_farms -pole_name = "bi-bio-farm-hidden-pole" -panel_name = "bi-bio-farm-hidden-panel" -lamp_name = "bi-bio-farm-light" - -cnt = 0 - -for s, surface in pairs(game.surfaces or {}) do - -- Find all bio_farms on surface! - bio_farms = surface.find_entities_filtered({name = "bi-bio-farm"}) - for b, bio_farm in ipairs(bio_farms or {}) do - -- Make a clean slate! - remove_entities(bio_farm, {pole_name, panel_name, lamp_name}) - - recreate_entities(global.bi_bio_farm_table, bio_farm, { - pole = pole_name, - panel = panel_name, - lamp = lamp_name - }) - - cnt = cnt + 1 - end -end -BioInd.writeDebug("Recreated hidden entities for %s Bio-farms.", {cnt}) - - ------------------------------------------------------------------------------------- --- Bio Solar Boiler/Solar Plant -- ------------------------------------------------------------------------------------- -cnt = 0 - --- Empty old list -for s, solar_boiler in pairs(global.bi_solar_boiler_table or {}) do - -- Remove hidden entities from solar_boilers in our table - remove_stored_entities(solar_boiler, {"pole", "boiler"}) - -- Remove entry from table - global.bi_solar_boiler_table[s] = nil - - cnt = cnt + 1 -end -BioInd.writeDebug("Removed hidden entities from %s Solar boilers/power plants.", {cnt}) - - --- Generate new list ---~ local solar_boilers, pole, boiler -local solar_boilers -pole_name = "bi-hidden-power-pole" -boiler_name = "bi-solar-boiler-hidden-panel" - -cnt = 0 - -for s, surface in pairs(game.surfaces or {}) do - -- Find all solar_boilers on surface! - solar_boilers = surface.find_entities_filtered({name = "bi-solar-boiler"}) - for b, boiler_solar in ipairs(solar_boilers or {}) do - -- Make a clean slate! - --~ remove_entities(boiler_solar, {pole_name, panel_name}) - remove_entities(boiler_solar, {boiler_name}) - - -- Recreate hidden entities - recreate_entities(global.bi_solar_boiler_table, boiler_solar, { - boiler = boiler_name, - pole = pole_name - }) - - cnt = cnt + 1 - end -end -BioInd.writeDebug("Recreated hidden entities for %s Solar boilers/power plants.", {cnt}) - - - ------------------------------------------------------------------------------------- --- Solar Farm -- ------------------------------------------------------------------------------------- -cnt = 0 - --- Empty old list -for s, solar_farm in pairs(global.bi_solar_farm_table or {}) do - --~ remove_stored_entities(solar_farm, {"pole"}) - -- Remove entry from table - global.bi_solar_farm_table[s] = nil - - cnt = cnt + 1 -end -BioInd.writeDebug("Removed hidden entities from %s Solar farms.", {cnt}) - - --- Generate new list -local solar_farms -pole_name = "bi-hidden-power-pole" - -cnt = 0 - -for s, surface in pairs(game.surfaces or {}) do - -- Find all solar_boilers on surface! - solar_farms = surface.find_entities_filtered({name = "bi-bio-solar-farm"}) - for sf, solar_farm in ipairs(solar_farms or {}) do - --~ -- Make a clean slate! - --~ remove_entities(solar_farm, {pole_name}) - -- Recreate hidden entities - recreate_entities(global.bi_solar_farm_table, solar_farm, {pole = pole_name}) - cnt = cnt + 1 - end -end -BioInd.writeDebug("Recreated hidden entities for %s Solar farms.", {cnt}) - - - ------------------------------------------------------------------------------------- --- Bio Cannon -- --- Bio Cannons have a different table format -- make that the same as the others -- ------------------------------------------------------------------------------------- -cnt = 0 - --- Empty old list -for b, bio_cannon in pairs(global.bi_bio_cannon_table or {}) do - -- Remove hidden entities from Bio cannons in our table - - if bio_cannon[2] and bio_cannon[2].valid then - bio_cannon[2].destroy() - end - -- Remove entry from table - global.bi_bio_cannon_table[b] = nil - - cnt = cnt + 1 -end -BioInd.writeDebug("Removed hidden entities from %s Bio-Cannons.", {cnt}) - - --- Generate new list ---~ local bio_cannons, base, radar -local bio_cannons -base_name = "bi-bio-cannon" -overlay_name = "bi-bio-cannon-area" -radar_name = "bi-bio-cannon-hidden-radar" - -cnt = 0 - -for s, surface in pairs(game.surfaces or {}) do - -- Find all cannons on surface! - bio_cannons = surface.find_entities_filtered({name = {base_name, overlay_name}}) - for b, bio_cannon in ipairs(bio_cannons or {}) do - -- Make a clean slate! - remove_entities(bio_cannon, {radar_name}) - -- Recreate hidden entities - radar = surface.create_entity({ - name = radar_name, - position = bio_cannon.position, - force = bio_cannon.force - }) - make_unminable({radar}) - -- Make sure we don't use the overlay cannon! - if bio_cannon.name == overlay_name then - -- Create final cannon - base = surface.create_entity({ - name = base_name, - position = bio_cannon.position, - force = bio_cannon.force - }) - -- Set its health to that of overlay - base.health = bio_cannon.health - -- Remove overlay - bio_cannon.destroy() - BioInd.writeDebug("Replaced Bio-cannon overlay with Bio-cannon %s.", {base.unit_number}) - else - base = bio_cannon - end - -- Add to table - global.bi_bio_cannon_table[base.unit_number] = { - base = base, - radar = radar, - -- Bio-cannons will be checked once per second. Delay is based on the ammo the - -- cannon is loaded with. Let's use 20s (delay for best ammo) initially! - delay = (base.unit_number * base.unit_number) % 20 - } - cnt = cnt + 1 - end -end -BioInd.writeDebug("Recreated hidden entities for %s Bio-cannons.", {cnt}) - - - ------------------------------------------------------------------------------------- --- Arboretum -- ------------------------------------------------------------------------------------- -cnt = 0 - --- Empty old list -for a, arboretum in pairs(global.bi_arboretum_table or {}) do - -- Remove hidden entities from solar_boilers in our table (Don't call removal - -- function because radar position has been shifted, so the radar won't be found!) - for e, entity in ipairs({"radar", "pole", "lamp"}) do - if arboretum[entity] and arboretum[entity].valid then - arboretum[entity].destroy() - end - end - --~ remove_stored_entities(arboretum, {"radar", "pole", "lamp"}) - -- Remove entry from table - global.bi_arboretum_table[a] = nil - - cnt = cnt + 1 -end -BioInd.writeDebug("Removed hidden entities from %s Arboretums.", {cnt}) - - --- Generate new list ---~ local arboretums, pole, radar, lamp -local arboretums -base_name = "bi-arboretum" -overlay_name = "bi-arboretum-area" -pole_name = "bi-hidden-power-pole" -radar_name = "bi-arboretum-hidden-radar" -lamp_name = "bi-bio-farm-light" - -cnt = 0 - --- We need to keep track of radars separately! -global.bi_arboretum_radar_table = {} - -for s, surface in pairs(game.surfaces or {}) do - -- Find all arboretums on surface! - arboretums = surface.find_entities_filtered({name = {base_name, overlay_name}}) - for a, arboretum in ipairs(arboretums or {}) do - -- Make a clean slate! - remove_entities(arboretum, {pole_name, radar_name, lamp_name}) - -- Recreate hidden entities - radar = surface.create_entity({ - name = radar_name, - position = {arboretum.position.x - 3.5, arboretum.position.y + 3.5}, - force = arboretum.force - }) - pole = surface.create_entity({ - name = pole_name, - position = arboretum.position, - force = arboretum.force - }) - lamp = surface.create_entity({ - name = lamp_name, - position = arboretum.position, - force = arboretum.force - }) - make_unminable({pole, radar, lamp}) - - -- Make sure we don't use the overlay! - if arboretum.name == overlay_name then - -- Create final arboretum - base = surface.create_entity({ - name = base_name, - position = arboretum.position, - force = arboretum.force - }) - -- Set its health to that of overlay - base.health = arboretum.health - -- Remove overlay - arboretum.destroy() - BioInd.writeDebug("Replaced Arboretum overlay with Arboretum %s.", {base.unit_number}) - else - base = arboretum - end -BioInd.writeDebug("Arboretum base: %g", {base.unit_number}) - -- Add to table - global.bi_arboretum_table[base.unit_number] = { - base = base, - pole = pole, - radar = radar, - lamp = lamp - } - -- Link radar to arboretum - global.bi_arboretum_radar_table[radar.unit_number] = base.unit_number - ---~ BioInd.writeDebug("Added new arboretum: %s", {global.bi_arboretum_table}) - - cnt = cnt + 1 - end -end -BioInd.writeDebug("Recreated hidden entities for %s Arboretums.", {cnt}) - - - ------------------------------------------------------------------------------------- --- Power Rail -- ------------------------------------------------------------------------------------- -cnt = 0 - --- Empty old list -for p, power_rail in pairs(global.bi_power_rail_table or {}) do - -- We can't remove all hidden poles at once because they are used in other compound - -- entities as well! - --~ remove_stored_entities(power_rail, {"pole"}) - -- Remove entry from table - global.bi_power_rail_table[p] = nil - cnt = cnt + 1 -end -BioInd.writeDebug("Removed hidden entities from %s Powered rails.", {cnt}) -BioInd.show("global.bi_power_rail_table", serpent.block(global.bi_power_rail_table)) - --- Generate new list -local power_rails, neighbour -pole_name = "bi-power-rail-hidden-pole" -cnt = 0 - -for s, surface in pairs(game.surfaces or {}) do - -- Find all power rails on surface (there may be some that haven't been in our table)! - power_rails = surface.find_entities_filtered({ - name = {"bi-straight-rail-power","bi-curved-rail-power"} - }) -BioInd.show("table_size(power_rails) after finding power_rails on surface", table_size(power_rails)) - -- Unlike the other entities, power rails interact with each other. So lets's - -- recreate all hidden poles and update our tables before trying to connect - -- the poles! - for p, power_rail in ipairs(power_rails or {}) do -BioInd.show("p", p) ---~ BioInd.show("power_rail.unit_number", power_rail.unit_number) - - --~ -- In case our tables haven't been properly updated, there may still be power - --~ -- rails with hidden entities around -- remove them! - --~ remove_entities(power_rail, {pole_name}) - - -- Recreate hidden entities - recreate_entities(global.bi_power_rail_table, power_rail, {pole = pole_name}) - - -- Disconnect pole - global.bi_power_rail_table[power_rail.unit_number].pole.disconnect_neighbour() - - end -BioInd.show("table_size(global.bi_power_rail_table)", table_size(global.bi_power_rail_table)) - - - -- Rewire the power rails! - for p, power_rail in pairs(global.bi_power_rail_table or {}) do -BioInd.show("p", p) ---~ BioInd.writeDebug("power_rail", {power_rail}, "line") - - base = power_rail.base - pole = power_rail.pole ---~ BioInd.show("base.valid", base.valid) ---~ BioInd.show("pole.valid", pole.valid) - - -- Look for connecting rails at front and back of the new rail - for s, side in ipairs( {"front", "back"} ) do -BioInd.writeDebug("Looking for rails at %s.\tbase.valid: %s\tpole.valid: %s", {side, base.valid, pole.valid}) - -- Look in all three directions - for d, direction in ipairs( {"left", "straight", "right"} ) do - neighbour = base.get_connected_rail{ - rail_direction = defines.rail_direction[side], - rail_connection_direction = defines.rail_connection_direction[direction] - } - -BioInd.writeDebug("Rail %s of %s (%g):\t%s (%s)", {direction, base.name, base.unit_number, (neighbour and neighbour.name or "nil"), (neighbour and neighbour.unit_number or "nil")}) - - -- Only make a connection if found rail is a powered rail - -- (We'll know it's the right type if we find it in our table!) - neighbour = neighbour and neighbour.valid and global.bi_power_rail_table[neighbour.unit_number] - if neighbour then ---~ BioInd.show("neighbour", neighbour) ---~ BioInd.show("neighbour.base", neighbour and neighbour.base and neighbour.base.valid and neighbour.base.unit_number) ---~ BioInd.show("neighbour.pole", neighbour and neighbour.pole and neighbour.pole.valid and neighbour.pole.unit_number) - pole.connect_neighbour(neighbour.pole) - BioInd.writeDebug("Connected poles!") - end - end - end - - -- Look for Power-rail connectors ---~ BioInd.show("base", base) ---~ BioInd.show("base.position", base.position) ---~ BioInd.show("pole", pole and pole.unit_number) ---~ BioInd.show("pole.valid", pole and pole.valid) - - connectors = surface.find_entities_filtered{ - position = base.position, - radius = BioInd.POWER_TO_RAIL_WIRE_DISTANCE, -- maximum_wire_distance of Power-to-rail-connectors - name = "bi-power-to-rail-pole" - } -BioInd.show("table_size(connectors)", table_size(connectors)) - - -- Connect to just one Power-rail connector! - for c, connector in ipairs(connectors or {}) do ---~ BioInd.writeDebug("Network ID pole %s: %s\tNetwork ID connector %s: %s", - --~ {pole.unit_number, pole.electric_network_id, connector.unit_number, connector.electric_network_id}) - if pole.electric_network_id ~= connector.electric_network_id then - pole.connect_neighbour(connector) -BioInd.writeDebug("Connected %s (%s) to connector %s (%s)", {pole.name, pole.unit_number, connector.name, connector.unit_number}) ---~ BioInd.writeDebug("Network ID pole %s: %s\tNetwork ID connector %s: %s", - --~ {pole.unit_number, pole.electric_network_id, connector.unit_number, connector.electric_network_id}) - break - end - end -BioInd.writeDebug("Finished search for connectors") - cnt = cnt + 1 - end -end -BioInd.writeDebug("Recreated hidden entities for %s Powered rails.", {cnt}) - - - ---~ ------------------------------------------------------------------------------------ ---~ -- Solar Farm -- ---~ ------------------------------------------------------------------------------------ ---~ cnt = 0 - ---~ -- Empty old list ---~ for s, solar_farm in pairs(global.bi_solar_farm_table or {}) do - --~ -- Remove hidden entities from solar_boilers in our table - - --~ -- Remove entry from table - --~ global.bi_solar_farm_table[s] = nil - - --~ cnt = cnt + 1 ---~ end ---~ BioInd.writeDebug("Removed hidden entities from %s Solar farms.", {cnt}) - - ---~ -- Generate new list ---~ pole_name = "bi-hidden-power-pole" - ---~ cnt = 0 - ---~ for s, surface in pairs(game.surfaces or {}) do - --~ -- Find all solar farms on surface! - --~ solar_farms = surface.find_entities_filtered({name = "bi-bio-solar-farm"}) - --~ for sf, solar_farm in ipairs(solar_farms or {}) do - -- Make a clean slate! - --~ -- Recreate hidden entities - --~ pole = surface.create_entity({ - --~ name = pole_name, - --~ position = solar_farm.position, - --~ force = solar_farm.force - --~ }) - --~ make_unminable({pole}) - --~ -- Add to table - --~ global.bi_solar_farm_table[solar_farm.unit_number] = { - --~ base = solar_farm, - --~ pole = pole - --~ } - --~ -- Recreate hidden entities - --~ recreate_entities(global.bi_solar_farm_table, solar_farm, {pole = pole_name}) - - --~ cnt = cnt + 1 - --~ end ---~ end ---~ BioInd.writeDebug("Recreated hidden entities for %s Solar farms.", {cnt}) - - ------------------------------------------------------------------------------------- --- Musk floor -- ------------------------------------------------------------------------------------- -cnt = 0 - --- Create tables for storing force information on tiles -global.bi_musk_floor_table = global.bi_musk_floor_table or {} --- Lookup table for force at tile position -global.bi_musk_floor_table.tiles = global.bi_musk_floor_table.tiles or {} --- Lookup table for tiles placed by force -global.bi_musk_floor_table.forces = global.bi_musk_floor_table.forces or {} - - -local musk_floor_tiles -local tile_name = "bi-solar-mat" -pole_name = "bi-musk-mat-hidden-pole" -panel_name = "bi-musk-mat-hidden-panel" -local pole_type = "electric-pole" -local panel_type = "solar-panel" - --- Remove panels and poles without tile from surfaces -local cnt_panel = 0 -local cnt_pole = 0 -for s, surface in pairs(game.surfaces or {}) do - local panels = surface.find_entities_filtered({name = panel_name, type = panel_type}) - for p, panel in ipairs(panels or {}) do - local x = surface.count_tiles_filtered({ - position = panel.position, - name = tile_name, - limit = 1 - }) - if x == 0 then - BioInd.writeDebug("Removing %s at position %s because there is no %s.", {panel.name, panel.position, tile_name}) - panel.destroy() - cnt_panel = cnt_panel + 1 - end - end - - local poles = surface.find_entities_filtered({name = pole_name, type = pole_type}) - for p, pole in ipairs(poles or {}) do - local x = surface.count_tiles_filtered({ - position = pole.position, - name = tile_name, - radius = 0.5, - limit = 1 - }) - if x == 0 then - BioInd.writeDebug("Removing %s at position %s because there is no %s.", {pole.name, pole.position, tile_name}) - pole.destroy() - cnt_pole = cnt_pole + 1 - end - end -end -BioInd.writeDebug("Removed %g hidden solar panels and %g hidden poles because they were not on %s.", {cnt_panel, cnt_pole, tile_name}) - -cnt_panel = 0 -cnt_pole = 0 --- Generate new list -local x, y, poles, pole, panels, panel, force_name -for s, surface in pairs(game.surfaces or {}) do - local tiles = surface.find_tiles_filtered{name = tile_name} - for t, tile in ipairs(tiles or {}) do - x = tile.position.x or tile.position[1] - y = tile.position.y or tile.position[2] - - -- Check that there's a solar panel - panels = surface.find_entities_filtered({ - position = {x + 0.5, y + 0.5}, - name = panel_name, - type = panel_type, - limit = 1 - }) - panel = panels and panels[1] - if panel then - force_name = panel.force and panel.force.name - end - - -- Check that there's a pole - panels = surface.find_entities_filtered({ - position = {x + 0.5, y + 0.5}, - name = pole_name, - type = pole_type, - limit = 1 - }) - pole = poles and poles[1] - if pole and not force then - force_name = pole.force and pole.force.name - end - - force_name = force_name or "BI-Musk_floor_general_owner" - - -- Create/set force for panel - if panel then - panel.force = force_name - else - panel = surface.create_entity({ - name = panel_name, - type = panel_type, - force = force_name, - position = {x + 0.5, y + 0.5}, - }) - cnt_panel = cnt_panel + 1 - end - -- Create/set force for pole - if pole then - pole.force = force_name - else - pole = surface.create_entity({ - name = pole_name, - type = pole_type, - force = force_name, - position = {x + 0.5, y + 0.5}, - }) - cnt_pole = cnt_pole + 1 - end - - make_unminable({panel, pole}) - - -- Add to global tables - global.bi_musk_floor_table.tiles[x] = global.bi_musk_floor_table.tiles[x] or {} - global.bi_musk_floor_table.tiles[x][y] = force_name - - global.bi_musk_floor_table.forces[force_name] = global.bi_musk_floor_table.forces[force_name] or {} - global.bi_musk_floor_table.forces[force_name][x] = global.bi_musk_floor_table.forces[force_name][x] or {} - global.bi_musk_floor_table.forces[force_name][x][y] = true - end -end -BioInd.writeDebug("Created %g hidden solar panels and %g hidden poles.\nglobal.bi_musk_floor_table.tiles: %s\nglobal.bi_musk_floor_table.forces: %s", {cnt_panel, cnt_pole, global.bi_musk_floor_table.tiles, global.bi_musk_floor_table.forces}) - -BioInd.show("table_size(created_entities)", table_size(created_entities)) -created_entities = nil diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.json b/Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.json deleted file mode 100644 index ce97ae4..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "item": - [ - ["fertiliser", "fertilizer"], - ["bi-adv-fertiliser", "bi-adv-fertilizer"] - ], - - "recipe": - [ - ["bi-adv-fertiliser-1", "bi-adv-fertilizer-1"], - ["bi-adv-fertiliser-2", "bi-adv-fertilizer-2"], - ["bi-fertiliser-1", "bi-fertilizer-1"], - ["bi-fertiliser-2", "bi-fertilizer-2"] - ], - - "technology": - [ - ["bi-tech-fertiliser", "bi-tech-fertilizer"] - ] -} diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.lua b/Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.lua deleted file mode 100644 index 36f76b2..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.31_+_1.01.01.lua +++ /dev/null @@ -1,12 +0,0 @@ ------------------------------------------------------------------------------------- --- Just remove some obsolete global tables! ------------------------------------------------------------------------------------- ---~ local BioInd = require('__Bio_Industries_2__/common')('Bio_Industries_2') - -if global and global.bi then - global.bi.terrains = nil - global.bi.seed_bomb = nil - BioInd.writeDebug("Removed obsolete tables from global!") -end - -table.sort(global, function(a, b) return a < b end) diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.32_+_1.01.02.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.32_+_1.01.02.lua.bak deleted file mode 100644 index ad7c999..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.32_+_1.01.02.lua.bak +++ /dev/null @@ -1,29 +0,0 @@ ------------------------------------------------------------------------------------- --- BioGardens will now have a hidden pole. It can't be hooked up unless Fluid --- fertilizer is active (maximum_wire_distance = 0), but it still needs to be there. ------------------------------------------------------------------------------------- -local BioInd = require('__Bio_Industries__/common')('Bio_Industries') - --- Make sure the global table exists! -global.bi_bio_garden_table = {} - -local bio_gardens = {} -local hidden_entities = {pole = "bi-bio-garden-hidden-pole"} - -for s, surface in pairs(game.surfaces) do - bio_gardens = surface.find_entities_filtered{ - name = "bi-bio-garden", - type = "assembling-machine", - } - - for g, garden in ipairs(bio_gardens or {}) do - --~ BioInd.create_entities(global.bi_bio_garden_table, garden, hidden_entities, garden.position) - BioInd.create_entities(global.bi_bio_garden_table, garden, hidden_entities) - BioInd.writeDebug("Stored Bio garden %g in table: %s", {garden.unit_number, global.bi_bio_garden_table[garden.unit_number]}) - end -end - - --- Create a table where we can store the last state of certain mod settings. -global.mod_settings = global.mod_settings or {} -global.mod_settings.BI_Easy_Bio_Gardens = BioInd.get_startup_setting("BI_Easy_Bio_Gardens") diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.34_+_1.01.04.lua.bak b/Bio_Industries_2/migrations/Bio_Industries_0.18.34_+_1.01.04.lua.bak deleted file mode 100644 index 0eab507..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.34_+_1.01.04.lua.bak +++ /dev/null @@ -1,122 +0,0 @@ -log("Entered migration script 1_00_04.lua of \"" .. script.mod_name .. "\".") - --- Add functions that are also used in other files (debugging output etc.) -local BioInd = require("__" .. script.mod_name .. "__.common")(script.mod_name) - ------------------------------------------------------------------------------------- --- Make sure that all compound entities have all the hidden entities they need! ------------------------------------------------------------------------------------- - --- Compile a list of the entities we need to consider (we can ignore overlay entities) -local check_entities = {} -for name, data in pairs(BioInd.compound_entities) do - if not name:match("^.+%-area$") then - check_entities[name] = data - end -end - - -local function add_hidden_entity(tab, base, hidden_entity) - local optional, pos - - local entity_name = check_entities[base.name].hidden[hidden_entity] - - ------------------------------------------------------------------------------------ - -- Pre-processing - ------------------------------------------------------------------------------------ - pos = BioInd.normalize_position(base.position) - - -- Bio cannon - if tab == "bi_bio_cannon_table" then - optional = {delay = 0} - - -- Arboretum - elseif tab == "bi_arboretum_table" and hidden_entity == "radar" then - -- Radar position is off! - pos = {pos.x - 3.5, pos.y + 3.5} - end -BioInd.show("base.unit_number", base.unit_number) -BioInd.show("size of global[tab]", table_size(global[tab])) - - - ------------------------------------------------------------------------------------ - -- Create hidden entity - ------------------------------------------------------------------------------------ - --~ BioInd.create_entities(global[tab], base, {[hidden_entity] = entity_name}, pos, optional) - BioInd.create_entities(global[tab], base, {[hidden_entity] = entity_name}, optional) - - ------------------------------------------------------------------------------------ - -- Post-processing - ------------------------------------------------------------------------------------ - -- Arboretum - if tab == "bi_arboretum_table" and hidden_entity == "radar" then - local radar = global[tab][base.unit_number].radar - global.bi_arboretum_radar_table[radar.unit_number] = base.unit_number - - -- Power Rail - elseif tab == "bi_power_rail_table" then - BioInd.connect_power_rail(base) - end - -end - - -local entity, entities - --- Find all compound entities -for s_name, surface in pairs(game.surfaces) do -BioInd.show("Looking for compound entities on surface", s_name) - - for entity_name, entity_data in pairs(check_entities) do -BioInd.show("Looking for", entity_name) - -- Get list of all base entities - entities = surface.find_entities_filtered({name = entity_name}) -BioInd.show("Number of found entities", #entities) - - -- Check the base entity is in the global table - global[entity_data.tab] = global[entity_data.tab] or {} - - for b, base in ipairs(entities) do - -- The base entity has been registered - if global[entity_data.tab][base.unit_number] then - entity = global[entity_data.tab][base.unit_number] -BioInd.writeDebug("%s is a registered entity. Checking hidden entities: %s", {BioInd.print_name_id(base), entity}) - -- Check hidden entities - for h_key, h_name in pairs(entity_data.hidden) do - -- Must add hidden entity - if not (entity[h_key] and entity[h_key].valid) then -BioInd.writeDebug("Adding hidden %s to %s", {h_key, BioInd.print_name_id(base)}) - add_hidden_entity(entity_data.tab, base, h_key) - -- Nothing to do - else -BioInd.writeDebug("%s is OK!", {BioInd.print_name_id(entity[h_key])}) - end - end - - -- Found unregistered entity! - else -BioInd.writeDebug("%s has not been registered. Adding hidden entities: %s", {BioInd.print_name_id(base), entity}) - -- Register base entity - global[entity_data.tab][base.unit_number] = {base = base} -BioInd.writeDebug("Added %s to global[%s]", {BioInd.print_name_id(base), entity_data.tab}) - -- Add hidden entities - for h_key, h_name in pairs(entity_data.hidden) do -BioInd.writeDebug("Adding hidden %s for %s", {h_key, BioInd.print_name_id(base)}) - add_hidden_entity(entity_data.tab, base, h_key) - end - end - - end - end -end - - ------------------------------------------------------------------------------------- --- Reset effects of researched technologies! ------------------------------------------------------------------------------------- -for force_name, force in pairs(game.forces) do - force.reset_technology_effects() - BioInd.show("Reset technology effects for force", force_name) -end - -log("End of migration script 1_00_04.lua of \"" .. script.mod_name .. "\".") diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.json b/Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.json deleted file mode 100644 index 89dd722..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "entity": - [ - ["bi-bio-farm-electric-pole", "bi-bio-farm-hidden-pole"], - ["bi-rail-hidden-power-pole", "bi-rail-power-hidden-pole"], - ["bi-musk-mat-pole", "bi-musk-mat-hidden-pole"], - - ["bi-bio-farm-solar-panel", "bi-bio-farm-hidden-panel"], - ["bi-musk-mat-solar-panel", "bi-musk-mat-hidden-panel"], - ["bi-solar-boiler-panel", "bi-solar-boiler-hidden-panel"], - - ["bi-arboretum-radar", "bi-arboretum-hidden-radar"], - ["Bio-Cannon-r", "bi-bio-cannon-hidden-radar"] - ] - -} - --~ ["bi-bio-farm-light", "bi-arboretum-hidden-lamp"], diff --git a/Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.lua b/Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.lua deleted file mode 100644 index 2078143..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_0.18.35_+_1.01.05.lua +++ /dev/null @@ -1,39 +0,0 @@ --- Add functions that are also used in other files (debugging output etc.) ---~ local BioInd = require("__" .. script.mod_name .. "__.common")(script.mod_name) -BioInd.writeDebug("Entered migration script 0.18.35+1.01.05") - ---~ require("util") - - --- Migrating global tables to new names -for new, old in pairs({ - bi_arboretum_table = "Arboretum_Table", - bi_arboretum_radar_table = "Arboretum_Radar_Table", - bi_arboretum_recipe_table = "Arboretum_Recipes", - bi_bio_cannon_table = "Bio_Cannon_Table", -}) do - - global[new] = util.table.deepcopy(global[old]) - global[old] = nil - BioInd.writeDebug("Migrated global[\"%s\"] to global[\"%s\"].", {old, new}) -end - --- Migrate renamed hidden entities! -local boilers = global["bi_solar_boiler_table"] - --- Check the entries of all solar boilers -for b, boiler in pairs(boilers or {}) do - if boiler.boiler then - -- Only "boiler" exists (default) - if not boiler.panel then - boiler.panel = boiler.boiler - boiler.boiler = nil - BioInd.writeDebug("Moved \"boiler\" to \"panel\" in global[\"bi_solar_boiler_table\"][%s]: %s", - {b, boilers[b]}) - -- This should never be needed! - else - boiler.boiler = nil - BioInd.writeDebug("\"Panel\" already exists! Removed \"boiler\" from global[\"bi_solar_boiler_table\"][%s]: %s", {b, boilers[b]}) - end - end -end diff --git a/Bio_Industries_2/migrations/Bio_Industries_1.01.19.lua b/Bio_Industries_2/migrations/Bio_Industries_1.01.19.lua deleted file mode 100644 index 791df3a..0000000 --- a/Bio_Industries_2/migrations/Bio_Industries_1.01.19.lua +++ /dev/null @@ -1,46 +0,0 @@ ---~ -- If a tutorial from Tips and Tricks is started, the migration will be applied to a ---~ -- mod named "level" and none of our global variables will be defined.) ---~ if script.mod_name ~= "autodrive" then - --~ AD.entered_file("leave", "Nothing to do for mod \""..script.mod_name.."\"!") - --~ return ---~ end ---~ AD.entered_file() - - --- Add functions that are also used in other files (debugging output etc.) ---~ local BioInd = require("__" .. script.mod_name .. "__.common")(script.mod_name) -BioInd.writeDebug("Entered migration script 1.01.19") - ---~ require("util") - - --- Restructure tables for growing trees. They used to be arrays of treedata that had --- to be resorted by treedata.time whenever a new tree was added, so we could stop --- the on_tick event when the treedata.time of the first array was in the future. --- Now we index these tables directly by tick, so we can skip sorting the tables. -local function convert_tab(tab) - local ret = {} - local tick - - for t, tree_data in pairs(tab) do - tick = tree_data.time - --~ tree_data.time = nil - - ret[tick] = ret[tick] or {} - table.insert(ret[tick], tree_data) - end - - return ret -end - -local tab = "tree_growing" -BioInd.writeDebug("Converting table global.bi[%s]", {tab}) -global.bi[tab] = convert_tab(global.bi[tab]) -BioInd.show("global.bi["..tab.."]", global.bi[tab]) - -for s = 1, 4 do - tab = "tree_growing_stage_"..s - BioInd.writeDebug("Converting table global.bi[%s]", {tab}) - global.bi[tab] = convert_tab(global.bi[tab]) -BioInd.show("global.bi["..tab.."]", global.bi[tab]) -end