From 2966df75bb2280837e14db9ca09b6436c438e5bf Mon Sep 17 00:00:00 2001 From: Brevven Date: Sun, 31 Jul 2022 14:08:23 -0700 Subject: [PATCH] up --- changelog.txt | 4 +++- data-util.lua | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 7d28811..9bf08f5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,9 +1,11 @@ --------------------------------------------------------------------------------------------------- Version: 0.0.12 -Date: +Date: 2022-08-01 Changes: - Accumulator recipe makes 2 now, but requires more batteries. - Minor, tweak a K2 recipe icon + - Tweak bakelite item icon + - If enabled, alternate phenol recipe allows productivity --------------------------------------------------------------------------------------------------- Version: 0.0.11 Date: 2022-07-31 diff --git a/data-util.lua b/data-util.lua index cda1241..1578b17 100644 --- a/data-util.lua +++ b/data-util.lua @@ -282,6 +282,26 @@ function add_product(recipe, product) end end +-- Get the amount of the ingredient, will check base/normal not expensive +function util.get_ingredient_amount(recipe_name, ingredient_name) + local recipe = data.raw.recipe[recipe_name] + if recipe then + if recipe.normal and recipe.normal.ingredients then + for i, ingredient in pairs(recipe.normal.ingredients) do + if ingredient[1] == ingredient_name then return ingredient[2] end + if ingredient.name == ingredient_name then return ingredient.amount end + end + elseif recipe.ingredients then + for i, ingredient in pairs(recipe.ingredients) do + if ingredient[1] == ingredient_name then return ingredient[2] end + if ingredient.name == ingredient_name then return ingredient.amount end + end + end + return 1 + end + return 0 +end + -- Get the amount of the result, will check base/normal not expensive function util.get_amount(recipe_name, product) if not product then product = recipe_name end