From 903c34b08ead281e11c01a8f96ccf6f049464aa5 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sat, 5 Jul 2025 17:10:44 +0200 Subject: [PATCH] Fix libs --- Bio_Industries_2/libs/item-functions.lua | 1 - Bio_Industries_2/libs/recipe-functions.lua | 244 +-------------------- 2 files changed, 2 insertions(+), 243 deletions(-) diff --git a/Bio_Industries_2/libs/item-functions.lua b/Bio_Industries_2/libs/item-functions.lua index f29d722..fb63750 100644 --- a/Bio_Industries_2/libs/item-functions.lua +++ b/Bio_Industries_2/libs/item-functions.lua @@ -11,7 +11,6 @@ function thxbob.lib.item.get_type(name) "fluid", "gun", "item", - "mining-tool", "module", "tool", "item-with-entity-data" diff --git a/Bio_Industries_2/libs/recipe-functions.lua b/Bio_Industries_2/libs/recipe-functions.lua index 271e60e..f8bb1db 100644 --- a/Bio_Industries_2/libs/recipe-functions.lua +++ b/Bio_Industries_2/libs/recipe-functions.lua @@ -8,7 +8,7 @@ function thxbob.lib.recipe.replace_ingredient(recipe, old, new) if data.raw.recipe[recipe] and thxbob.lib.item.get_type(new) then local amount = 0 - if data.raw.recipe[recipe].ingredients and not data.raw.recipe[recipe].normal and not data.raw.recipe[recipe].expensive then + if data.raw.recipe[recipe].ingredients then for i, ingredient in pairs(data.raw.recipe[recipe].ingredients) do local item = thxbob.lib.item.basic_item(ingredient) if item.name == old then @@ -29,51 +29,6 @@ function thxbob.lib.recipe.replace_ingredient(recipe, old, new) return false end end - - --~ local retval = false - if data.raw.recipe[recipe].normal then - amount = 0 - for i, ingredient in pairs(data.raw.recipe[recipe].normal.ingredients) do - local item = thxbob.lib.item.basic_item(ingredient) - if item.name == old then - amount = item.amount + amount - end - end - if amount > 0 then - if thxbob.lib.item.get_type(old) == "fluid" and thxbob.lib.item.get_type(new) == "item" then - amount = math.ceil(amount / 10) - end - if thxbob.lib.item.get_type(old) == "item" and thxbob.lib.item.get_type(new) == "fluid" then - amount = amount * 10 - end - thxbob.lib.recipe.remove_difficulty_ingredient(recipe, "normal", old) - thxbob.lib.recipe.add_difficulty_ingredient(recipe, "normal", {new, amount}) - retval = true - end - end - - if data.raw.recipe[recipe].expensive then - amount = 0 - for i, ingredient in pairs(data.raw.recipe[recipe].expensive.ingredients) do - local item = thxbob.lib.item.basic_item(ingredient) - if item.name == old then - amount = item.amount + amount - end - end - if amount > 0 then - if thxbob.lib.item.get_type(old) == "fluid" and thxbob.lib.item.get_type(new) == "item" then - amount = math.ceil(amount / 10) - end - if thxbob.lib.item.get_type(old) == "item" and thxbob.lib.item.get_type(new) == "fluid" then - amount = amount * 10 - end - thxbob.lib.recipe.remove_difficulty_ingredient(recipe, "expensive", old) - thxbob.lib.recipe.add_difficulty_ingredient(recipe, "expensive", {new, amount}) - retval = true - end - end - - --~ return retval else if not data.raw.recipe[recipe] then BioInd.writeDebug("Recipe %s does not exist.", {recipe}) @@ -101,13 +56,6 @@ end function thxbob.lib.recipe.remove_ingredient(recipe, item) if data.raw.recipe[recipe] then - - if data.raw.recipe[recipe].expensive then - thxbob.lib.item.remove(data.raw.recipe[recipe].expensive.ingredients, item) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.item.remove(data.raw.recipe[recipe].normal.ingredients, item) - end if data.raw.recipe[recipe].ingredients then thxbob.lib.item.remove(data.raw.recipe[recipe].ingredients, item) end @@ -120,13 +68,6 @@ end function thxbob.lib.recipe.add_new_ingredient(recipe, item) if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) then - - if data.raw.recipe[recipe].expensive then - thxbob.lib.item.add_new(data.raw.recipe[recipe].expensive.ingredients, thxbob.lib.item.basic_item(item)) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.item.add_new(data.raw.recipe[recipe].normal.ingredients, thxbob.lib.item.basic_item(item)) - end if data.raw.recipe[recipe].ingredients then thxbob.lib.item.add_new(data.raw.recipe[recipe].ingredients, thxbob.lib.item.basic_item(item)) end @@ -143,13 +84,6 @@ end function thxbob.lib.recipe.add_ingredient(recipe, item) if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) then - - if data.raw.recipe[recipe].expensive then - thxbob.lib.item.add(data.raw.recipe[recipe].expensive.ingredients, thxbob.lib.item.basic_item(item)) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.item.add(data.raw.recipe[recipe].normal.ingredients, thxbob.lib.item.basic_item(item)) - end if data.raw.recipe[recipe].ingredients then thxbob.lib.item.add(data.raw.recipe[recipe].ingredients, thxbob.lib.item.basic_item(item)) end @@ -166,13 +100,6 @@ end function thxbob.lib.recipe.set_ingredient(recipe, item) if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) then - - if data.raw.recipe[recipe].expensive then - thxbob.lib.item.set(data.raw.recipe[recipe].expensive.ingredients, thxbob.lib.item.basic_item(item)) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.item.set(data.raw.recipe[recipe].normal.ingredients, thxbob.lib.item.basic_item(item)) - end if data.raw.recipe[recipe].ingredients then thxbob.lib.item.set(data.raw.recipe[recipe].ingredients, thxbob.lib.item.basic_item(item)) end @@ -190,14 +117,6 @@ end function thxbob.lib.recipe.add_result(recipe, item) if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) then - if data.raw.recipe[recipe].expensive then - thxbob.lib.result_check(data.raw.recipe[recipe].expensive) - thxbob.lib.item.add(data.raw.recipe[recipe].expensive.results, item) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.result_check(data.raw.recipe[recipe].normal) - thxbob.lib.item.add(data.raw.recipe[recipe].normal.results, item) - end if data.raw.recipe[recipe].result or data.raw.recipe[recipe].results then thxbob.lib.result_check(data.raw.recipe[recipe]) thxbob.lib.item.add(data.raw.recipe[recipe].results, item) @@ -215,15 +134,6 @@ end function thxbob.lib.recipe.set_result(recipe, item) if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) then - - if data.raw.recipe[recipe].expensive then - thxbob.lib.result_check(data.raw.recipe[recipe].expensive) - thxbob.lib.item.set(data.raw.recipe[recipe].expensive.results, item) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.result_check(data.raw.recipe[recipe].normal) - thxbob.lib.item.set(data.raw.recipe[recipe].normal.results, item) - end if data.raw.recipe[recipe].result or data.raw.recipe[recipe].results then thxbob.lib.result_check(data.raw.recipe[recipe]) thxbob.lib.item.set(data.raw.recipe[recipe].results, item) @@ -243,15 +153,6 @@ function thxbob.lib.recipe.remove_result(recipe, item) local f_name = "remove_result" BioInd.writeDebug("Entered function %s(%s, %s)", {f_name, recipe, item}) if data.raw.recipe[recipe] then - - if data.raw.recipe[recipe].expensive then - thxbob.lib.result_check(data.raw.recipe[recipe].expensive) - thxbob.lib.item.remove(data.raw.recipe[recipe].expensive.results, item) - end - if data.raw.recipe[recipe].normal then - thxbob.lib.result_check(data.raw.recipe[recipe].normal) - thxbob.lib.item.remove(data.raw.recipe[recipe].normal.results, item) - end if data.raw.recipe[recipe].result or data.raw.recipe[recipe].results then thxbob.lib.result_check(data.raw.recipe[recipe]) thxbob.lib.item.remove(data.raw.recipe[recipe].results, item) @@ -260,145 +161,4 @@ BioInd.writeDebug("Entered function %s(%s, %s)", {f_name, recipe, item}) else BioInd.writeDebug("Recipe %s does not exist.", {recipe}) end -end - - - -local function split_line(recipe, tag) - if data.raw.recipe[recipe][tag] then - if not data.raw.recipe[recipe].normal[tag] then - data.raw.recipe[recipe].normal[tag] = table.deepcopy(data.raw.recipe[recipe][tag]) - end - if not data.raw.recipe[recipe].expensive[tag] then - data.raw.recipe[recipe].expensive[tag] = table.deepcopy(data.raw.recipe[recipe][tag]) - end - end -end - - -function thxbob.lib.recipe.difficulty_split(recipe) - if data.raw.recipe[recipe] then - if not data.raw.recipe[recipe].normal then - data.raw.recipe[recipe].normal = {} - end - if not data.raw.recipe[recipe].expensive then - data.raw.recipe[recipe].expensive = {} - end - split_line(recipe, "energy_required") - if data.raw.recipe[recipe].enabled == false then - if data.raw.recipe[recipe].normal.enabled ~= true then - data.raw.recipe[recipe].normal.enabled = false - end - if data.raw.recipe[recipe].expensive.enabled ~= true then - data.raw.recipe[recipe].expensive.enabled = false - end - end - split_line(recipe, "ingredients") - split_line(recipe, "result") - split_line(recipe, "results") - split_line(recipe, "result_count") - split_line(recipe, "requester_paste_multiplier") - else - BioInd.writeDebug("Recipe %s does not exist.", {recipe}) - end -end - - - -function thxbob.lib.recipe.remove_difficulty_ingredient(recipe, difficulty, item) - if data.raw.recipe[recipe] and (difficulty == "normal" or difficulty == "expensive") then - - if not data.raw.recipe[recipe][difficulty] then - thxbob.lib.recipe.difficulty_split(recipe) - end - thxbob.lib.item.remove(data.raw.recipe[recipe][difficulty].ingredients, item) - - else - BioInd.writeDebug("Recipe %s does not exist.", {recipe}) - end -end - - -function thxbob.lib.recipe.add_new_difficulty_ingredient(recipe, difficulty, item) - if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) and (difficulty == "normal" or difficulty == "expensive") then - - if not data.raw.recipe[recipe][difficulty] then - thxbob.lib.recipe.difficulty_split(recipe) - end - thxbob.lib.item.add_new(data.raw.recipe[recipe][difficulty].ingredients, thxbob.lib.item.basic_item(item)) - - else - if not data.raw.recipe[recipe] then - BioInd.writeDebug("Recipe %s does not exist.", {recipe}) - end - if not thxbob.lib.item.get_type(item) then - BioInd.writeDebug("Ingredient %s does not exist.", {thxbob.lib.item.basic_item(item).name}) - end - if not (difficulty == "normal" or difficulty == "expensive") then - BioInd.writeDebug("Difficulty %s is invalid.", {difficulty}) - end - end -end - -function thxbob.lib.recipe.add_difficulty_ingredient(recipe, difficulty, item) - if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) and (difficulty == "normal" or difficulty == "expensive") then - - if not data.raw.recipe[recipe][difficulty] then - thxbob.lib.recipe.difficulty_split(recipe) - end - thxbob.lib.item.add(data.raw.recipe[recipe][difficulty].ingredients, thxbob.lib.item.basic_item(item)) - - else - if not data.raw.recipe[recipe] then - BioInd.writeDebug("Recipe %s does not exist.", {recipe}) - end - if not thxbob.lib.item.get_basic_type(thxbob.lib.item.basic_item(item).name) then - BioInd.writeDebug("Ingredient %s does not exist.", {thxbob.lib.item.basic_item(item).name}) - end - if not (difficulty == "normal" or difficulty == "expensive") then - BioInd.writeDebug("Difficulty %s is invalid.", {difficulty}) - end - end -end - - -function thxbob.lib.recipe.add_difficulty_result(recipe, difficulty, item) - if data.raw.recipe[recipe] and thxbob.lib.item.get_type(thxbob.lib.item.basic_item(item).name) and (difficulty == "normal" or difficulty == "expensive") then - - if not data.raw.recipe[recipe][difficulty] then - thxbob.lib.recipe.difficulty_split(recipe) - end - thxbob.lib.result_check(data.raw.recipe[recipe][difficulty]) - thxbob.lib.item.add(data.raw.recipe[recipe][difficulty].results, item) - - else - if not data.raw.recipe[recipe] then - BioInd.writeDebug("Recipe %s does not exist.", {recipe}) - end - if not thxbob.lib.item.get_basic_type(thxbob.lib.item.basic_item(item).name) then - BioInd.writeDebug("Item %s does not exist.", {thxbob.lib.item.basic_item(item).name}) - end - if not (difficulty == "normal" or difficulty == "expensive") then - BioInd.writeDebug("Difficulty %s is invalid.", {difficulty}) - end - end -end - -function thxbob.lib.recipe.remove_difficulty_result(recipe, difficulty, item) - if data.raw.recipe[recipe] and (difficulty == "normal" or difficulty == "expensive") then - - if not data.raw.recipe[recipe][difficulty] then - thxbob.lib.recipe.difficulty_split(recipe) - end - thxbob.lib.result_check(data.raw.recipe[recipe][difficulty]) - thxbob.lib.item.remove(data.raw.recipe[recipe][difficulty].results, item) - - else - if not data.raw.recipe[recipe] then - BioInd.writeDebug("Recipe %s does not exist.", {recipe}) - end - if not (difficulty == "normal" or difficulty == "expensive") then - BioInd.writeDebug("Difficulty %s is invalid.", {difficulty}) - end - end -end +end \ No newline at end of file