hot metals support

This commit is contained in:
Brevven 2025-01-01 03:59:07 -08:00
parent 50843bd6e1
commit 60fcf04cf0
4 changed files with 68 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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()