From 7e51d2cde108f2cc53fb2c26b17e2855e52c4119 Mon Sep 17 00:00:00 2001 From: PreLeyZero Date: Wed, 8 Jun 2022 00:55:23 +0200 Subject: [PATCH] bounding box fix 2 --- data-final-fixes.lua | 2 ++ prototypes/electronic/el_solar.lua | 9 ++----- prototypes/fission/fi_crafter.lua | 10 +++---- prototypes/gravitation/gr_crafter.lua | 10 +++---- scripts/krastorio2/overhaul.lua | 2 -- scripts/upgrades.lua | 39 +++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 scripts/upgrades.lua diff --git a/data-final-fixes.lua b/data-final-fixes.lua index c844783..11a7ac0 100644 --- a/data-final-fixes.lua +++ b/data-final-fixes.lua @@ -1,3 +1,5 @@ +--fix upgradeables bounding boxes +require('scripts/upgrades') --insert tech if data.raw.lab['lab'] then table.insert(data.raw.lab['lab'].inputs, 'fi_ki_science') diff --git a/prototypes/electronic/el_solar.lua b/prototypes/electronic/el_solar.lua index 51f387b..279386c 100644 --- a/prototypes/electronic/el_solar.lua +++ b/prototypes/electronic/el_solar.lua @@ -63,7 +63,7 @@ data:extend({ usage_priority = 'solar', input_flow_limit = '0W', }, - fast_replaceable_group = 'solar-panel', + --fast_replaceable_group = 'solar-panel', production = solar_output(), --picture picture = { @@ -74,9 +74,4 @@ data:extend({ }, map_color = {r=1.7,g=1.7,b=1.7}, }, -}) - -if data.raw["solar-panel"]["solar-panel"] then - data.raw["solar-panel"]["solar-panel"].next_upgrade = "el_solar_entity" - data.raw["solar-panel"]["solar-panel"].fast_replaceable_group = "solar-panel" -end \ No newline at end of file +}) \ No newline at end of file diff --git a/prototypes/fission/fi_crafter.lua b/prototypes/fission/fi_crafter.lua index 099586f..f40720d 100644 --- a/prototypes/fission/fi_crafter.lua +++ b/prototypes/fission/fi_crafter.lua @@ -33,15 +33,15 @@ data:extend({ flags = {"player-creation","placeable-neutral"}, max_health = 300, corpse = 'big-remnants', - collision_box = data.raw['assembling-machine']['assembling-machine-1'].collision_box, - selection_box = data.raw['assembling-machine']['assembling-machine-1'].selection_box, + collision_box = data.raw['assembling-machine']['assembling-machine-3'].collision_box, + selection_box = data.raw['assembling-machine']['assembling-machine-3'].selection_box, squeak_behaviour = false, map_color = {r=0, g=0, b=1, a=1}, minable = { mining_time = 1, result = 'fi_crafter_item', }, - fast_replaceable_group = "assembling-machine", + --fast_replaceable_group = "assembling-machine", crafting_categories = {'advanced-crafting','crafting','smelting','fi_crafting_category'}, crafting_speed = 3.5, energy_source = { @@ -107,6 +107,4 @@ data:extend({ apparent_volume = 0.7, }, }, -}) - -data.raw['assembling-machine']['assembling-machine-3'].next_upgrade = 'fi_crafter_entity' \ No newline at end of file +}) \ No newline at end of file diff --git a/prototypes/gravitation/gr_crafter.lua b/prototypes/gravitation/gr_crafter.lua index dde0e6b..948b483 100644 --- a/prototypes/gravitation/gr_crafter.lua +++ b/prototypes/gravitation/gr_crafter.lua @@ -33,15 +33,15 @@ data:extend({ flags = {"player-creation","placeable-neutral"}, max_health = 300, corpse = 'big-remnants', - collision_box = data.raw['assembling-machine']['assembling-machine-1'].collision_box, - selection_box = data.raw['assembling-machine']['assembling-machine-1'].selection_box, + collision_box = data.raw['assembling-machine']['assembling-machine-3'].collision_box, + selection_box = data.raw['assembling-machine']['assembling-machine-3'].selection_box, squeak_behaviour = false, map_color = {r=0, g=0, b=1, a=1}, minable = { mining_time = 1, result = 'gr_crafter_item', }, - fast_replaceable_group = "assembling-machine", + --fast_replaceable_group = "assembling-machine", crafting_categories = {'advanced-crafting','crafting','smelting','fi_crafting_category'}, crafting_speed = 10, energy_source = { @@ -102,6 +102,4 @@ data:extend({ apparent_volume = 0.7, }, }, -}) - -data.raw['assembling-machine']['fi_crafter_entity'].next_upgrade = 'gr_crafter_entity' \ No newline at end of file +}) \ No newline at end of file diff --git a/scripts/krastorio2/overhaul.lua b/scripts/krastorio2/overhaul.lua index e8df803..387f245 100644 --- a/scripts/krastorio2/overhaul.lua +++ b/scripts/krastorio2/overhaul.lua @@ -410,9 +410,7 @@ pre_tech_table = { -- changes in entities and other protypes --=================================================================================================================== -data.raw["solar-panel"]["solar-panel"].next_upgrade = "el_solar_entity" data.raw["solar-panel"]["el_solar_entity"].production = "220kW" -data.raw["solar-panel"]["el_solar_entity"].next_upgrade = "kr-advanced-solar-panel" data.raw["solar-panel"]["kr-advanced-solar-panel"].production = "480kW" data.raw.item["el_materials_ALK"].stack_size = 200 data.raw.recipe["dt-fuel"].ingredients = { diff --git a/scripts/upgrades.lua b/scripts/upgrades.lua new file mode 100644 index 0000000..a949646 --- /dev/null +++ b/scripts/upgrades.lua @@ -0,0 +1,39 @@ +--table of entites that need to be fixed +--first arg = entity name, second arg = entity to copy bounfing box from, third arg = entity index in data raw +affected_entities = { + {"el_solar_entity", "solar-panel", "solar-panel"}, + {"fi_crafter_entity", "assembling-machine-3", "assembling-machine"}, + {"gr_crafter_entity", "assembling-machine-3", "assembling-machine"}, +} + +local function adjust_bounding_boxes(table_in) + --loop over all affected entities + for i,v in ipairs(table_in) do + --set bounding box to be same as entity to copy from + data.raw[v[3]][v[1]].collision_box = data.raw[v[3]][v[2]].collision_box + data.raw[v[3]][v[1]].selection_box = data.raw[v[3]][v[2]].selection_box + + --set fast_replaceable_group + data.raw[v[3]][v[1]].fast_replaceable_group = v[3] + + --collision mask + data.raw[v[3]][v[1]].collision_mask = data.raw[v[3]][v[2]].collision_mask + + --bounding box + data.raw[v[3]][v[1]].bounding_box = data.raw[v[3]][v[2]].bounding_box + end +end + +adjust_bounding_boxes(affected_entities) + +--set next upgrades +data.raw['assembling-machine']['fi_crafter_entity'].next_upgrade = 'gr_crafter_entity' +data.raw['assembling-machine']['assembling-machine-3'].next_upgrade = 'fi_crafter_entity' +data.raw["solar-panel"]["solar-panel"].next_upgrade = "el_solar_entity" +data.raw["solar-panel"]["solar-panel"].fast_replaceable_group = "solar-panel" + +if not mods["space-exploration"] then + if mods["Krastorio2"] then + data.raw["solar-panel"]["el_solar_entity"].next_upgrade = "kr-advanced-solar-panel" + end +end