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
Changes:
- 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
Date: 09.01.2025

View file

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

View file

@ -27,8 +27,15 @@ function createHotVariant(item)
-- Change recipes
for _, recipe in pairs(data.raw.recipe) do
if contains(HotMetals.craftingCategories, recipe.category) and recipe.results[1].name == itemName then
recipe.results[1].name = hotItem.name
if contains(HotMetals.craftingCategories, recipe.category) then
local function isResultMatch(result)
return result.name == itemName
end
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
@ -37,6 +44,7 @@ function createHotVariant(item)
recipe.result_is_always_fresh = true
end
end
end
-- Change technology triggers
for _, tech in pairs(data.raw.technology) do