Recipe code now also works if the main result is not the first result in the results list

This commit is contained in:
Simon Brodtmann 2025-02-02 17:16:29 +01:00
parent a49891d547
commit e2739df5ca
3 changed files with 18 additions and 8 deletions

View file

@ -3,6 +3,7 @@ Version: 1.2.2
Date: 02.02.2025 Date: 02.02.2025
Changes: Changes:
- Recipes always output "fresh" hot metals (https://mods.factorio.com/mod/hot-metals/discussion/6775293c1c4d7b0e4bba8648) - Recipes always output "fresh" hot metals (https://mods.factorio.com/mod/hot-metals/discussion/6775293c1c4d7b0e4bba8648)
- Recipe code now also works if the main result is not the first result in the results list
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
Version: 1.2.1 Version: 1.2.1
Date: 09.01.2025 Date: 09.01.2025

View file

@ -7,7 +7,8 @@
"homepage": "", "homepage": "",
"factorio_version": "2.0", "factorio_version": "2.0",
"dependencies": [ "dependencies": [
"base" "base",
"cf-lib >= 0.0.2"
], ],
"spoiling_required": true "spoiling_required": true
} }

View file

@ -27,14 +27,22 @@ function createHotVariant(item)
-- Change recipes -- Change recipes
for _, recipe in pairs(data.raw.recipe) do for _, recipe in pairs(data.raw.recipe) do
if contains(HotMetals.craftingCategories, recipe.category) and recipe.results[1].name == itemName then if contains(HotMetals.craftingCategories, recipe.category) then
recipe.results[1].name = hotItem.name local function isResultMatch(result)
recipe.localised_name = { "item-name." .. itemName } return result.name == itemName
if recipe.main_product == itemName then end
recipe.main_product = hotItem.name local results = table.filter(recipe.results, isResultMatch)
if #results > 0 then
for _, result in pairs(results) do
result.name = hotItem.name
end
recipe.localised_name = { "item-name." .. itemName }
if recipe.main_product == itemName then
recipe.main_product = hotItem.name
end
recipe.preserve_products_in_machine_output = true
recipe.result_is_always_fresh = true
end end
recipe.preserve_products_in_machine_output = true
recipe.result_is_always_fresh = true
end end
end end