Skip to content

Commit

Permalink
warn on mismatched cage recipes in dev mode
Browse files Browse the repository at this point in the history
probably needs more logic but it's a start
  • Loading branch information
oorzkws committed Sep 11, 2024
1 parent 63bca72 commit a2bae74
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions data-final-fixes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ for _, recipe in pairs(data.raw.recipe) do
local name = result.name or result[1]
local amount = result.amount or result[2]
if not name or not config.NON_PRODDABLE_ITEMS[name] or result.catalyst_amount then
goto NEXT_INGREDIENT
goto NEXT_RESULT
end
-- Convert to an explicitly long-form result format
if result[1] then
Expand All @@ -77,12 +77,48 @@ for _, recipe in pairs(data.raw.recipe) do
else -- Just set the catalyst amount
result.catalyst_amount = amount
end
::NEXT_INGREDIENT::
::NEXT_RESULT::
end
end
::NEXT_RECIPE::
end

-- Scan for cages
if dev_mode then
for recipe_name, recipe in pairs(data.raw.recipe) do
if not recipe.ingredients then
goto NEXT_RECIPE_CAGECHECK
end
local cage_input = false
local cage_output = false
for i, ingredient in pairs(recipe.ingredients) do
local item_name = ingredient[1] or ingredient.name
if item_name:find('caged') then
cage_input = true
break
end
end
if not cage_input then
goto NEXT_RECIPE_CAGECHECK
end
if not recipe.results then
-- Don't log, probably a voiding recipe
goto NEXT_RECIPE_CAGECHECK
end
for i, result in pairs(recipe.results) do
local item_name = result[1] or result.name
if item_name:find('cage') then -- could be the same caged animal or an empty cage
cage_output = true
break
end
end
if cage_input and not cage_output then
log(string.format('Recipe \'%s\' takes a caged animal as input but does not return a cage', recipe_name))
end
::NEXT_RECIPE_CAGECHECK::
end
end

-------------------------------------------
-- Resource category locale builder --
-------------------------------------------
Expand Down

0 comments on commit a2bae74

Please sign in to comment.