From f1fa7c51d067b95b5645c68cfdc7b58b19b032a0 Mon Sep 17 00:00:00 2001 From: Brevven Date: Mon, 31 Jan 2022 20:29:05 -0800 Subject: [PATCH] update --- data-util.lua | 34 ++++++++++++++++++++++++++++++++++ info.json | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/data-util.lua b/data-util.lua index d794286..38e91d0 100644 --- a/data-util.lua +++ b/data-util.lua @@ -177,6 +177,31 @@ function add_ingredient(recipe, ingredient, quantity) end end +-- Add a given ingredient prototype to a given recipe +function util.add_ingredient_raw(recipe_name, ingredient) + if me.bypass[recipe_name] then return end + if data.raw.recipe[recipe_name] and (data.raw.item[ingredient.name] or data.raw.item[ingredient[1]]) then + me.add_modified(recipe_name) + add_ingredient_raw(data.raw.recipe[recipe_name], ingredient) + add_ingredient_raw(data.raw.recipe[recipe_name].normal, ingredient) + add_ingredient_raw(data.raw.recipe[recipe_name].expensive, ingredient) + end +end + +function add_ingredient_raw(recipe, ingredient) + if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if ( + (existing[1] and (existing[1] == ingredient[1] or existing[1] == ingredient.name)) or + (existing.name and (existing.name == ingredient[1] or existing.name == ingredient.name)) + ) then + return + end + end + table.insert(recipe.ingredients, ingredient) + end +end + -- Set an ingredient to a given quantity function util.set_ingredient(recipe_name, ingredient, quantity) if me.bypass[recipe_name] then return end @@ -514,6 +539,15 @@ function util.set_icons(recipe_name, icons) end end +-- Set recipe icons +function util.set_item_icons(item_name, icons) + if data.raw.recipe[item_name] then + data.raw.recipe[item_name].icons = icons + data.raw.recipe[item_name].icon = nil + data.raw.recipe[item_name].icon_size = nil + end +end + function util.set_to_founding(recipe) util.set_category(recipe, "founding") util.set_subgroup(recipe, "foundry-intermediate") diff --git a/info.json b/info.json index 575a739..0321fed 100644 --- a/info.json +++ b/info.json @@ -1,5 +1,5 @@ { "name": "bztungsten", - "version": "0.5.4", + "version": "0.5.5", "factorio_version": "1.1", "title": "Tungsten", "author": "Brevven",