diff --git a/changelog.txt b/changelog.txt index bea4529..ca436b2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -5,6 +5,7 @@ Date: 2024-12-31 - Organotins will show up in a better location in places like Factoriopedia - Tweak bronze plate icon Features: + - Supports Hot metals mod. - Add casting recipes for solder, and bronze if enabled. --------------------------------------------------------------------------------------------------- Version: 2.0.0 diff --git a/compatibility/data/hot-metals.lua b/compatibility/data/hot-metals.lua new file mode 100644 index 0000000..7f81ec8 --- /dev/null +++ b/compatibility/data/hot-metals.lua @@ -0,0 +1,32 @@ +local util = require("data-util"); + +util.add_hot_metals({ + {name="tin-plate", spoilTicks=20*60, icons={ + { icon = "__bztin__/graphics/icons/tin-plate.png", icon_size = 128}, + { icon = "__bztin__/graphics/icons/tin-plate.png", icon_size = 128, tint={.9,.2,0, .5}}, + }}, + {name="bronze-plate", spoilTicks=20*60, icons={ + { icon = "__bztin__/graphics/icons/bronze-plate.png", icon_size = 128}, + { icon = "__bztin__/graphics/icons/bronze-plate.png", icon_size = 128, tint={.9,.2,0, .5}}, + }}, + {name="tinned-cable", spoilTicks=20*60, icons={ + { icon = "__bztin__/graphics/icons/tinned-cable.png", icon_size = 64}, + { icon = "__bztin__/graphics/icons/tinned-cable.png", icon_size = 64, tint={.9,.2,0, .5}}, + }}, + {name="solder", spoilTicks=5*60, icons={ + { icon = "__bztin__/graphics/icons/solder.png", icon_size = 128}, + { icon = "__bztin__/graphics/icons/solder.png", icon_size = 128, tint={.9,.2,0, .5}}, + }}, +}) + +if HotMetals then + if not data.raw["recipe-category"]["advanced-crafting-hot"] then + data:extend({{ + type="recipe-category", + name="advanced-crafting-hot", + }}) + table.insert(HotMetals.craftingCategories, "advanced-crafting-hot") + util.add_crafting_category_if("assembling-machine", "advanced-crafting-hot", "advanced-crafting") + end + util.set_category("bronze-plate", "advanced-crafting-hot") +end diff --git a/data-util.lua b/data-util.lua index f625890..de873bd 100644 --- a/data-util.lua +++ b/data-util.lua @@ -165,6 +165,17 @@ function util.use_fluid_mining_final() end end +-- If Hot metals mod is enabled, mark these metals as hot +function util.add_hot_metals(metals) + if HotMetals and HotMetals.items then + for _, metal in pairs(metals) do + if data.raw.item[metal] or (metal.name and data.raw.item[metal.name]) then + table.insert(HotMetals.items, metal) + end + end + end +end + -- se landfill -- params: ore, icon_size @@ -1133,6 +1144,28 @@ function util.add_crafting_category(entity_type, entity, category) end end +-- Add crafting category to all entities that have another category +function util.add_crafting_category_if(entity_type, category, other_category) + if data.raw[entity_type] and data.raw["recipe-category"][category] and data.raw["recipe-category"][other_category] then + for _, entity in pairs(data.raw[entity_type]) do + local found_good = false + local found_bad = false + for _, existing in pairs(entity.crafting_categories) do + if existing == other_category then + found_good = true + end + if existing == category then + found_bad = true + end + end + if found_good and not found_bad then + table.insert(entity.crafting_categories, category) + end + end + end +end + + function util.add_to_ingredient(recipe, ingredient, amount, options) if not should_force(options) and bypass(recipe_name) then return end if data.raw.recipe[recipe] then diff --git a/data.lua b/data.lua index 8eaf6c1..ac9c4e3 100644 --- a/data.lua +++ b/data.lua @@ -3,8 +3,10 @@ require("tin-ore") require("tin-recipe") require("tin-enriched") -- Enriched Al for Krastorio 2 require("tin-recipe-se") -- Space Exploration +require("compatibility.data.hot-metals") local util = require("data-util"); + -- Must be last util.create_list()