Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bobmods.lib.recipe.replace_ingredient(recipe, old, new)
- print("Hello from replace_ingredient in bobs!")
- print("Recipe: "..recipe)
- print("HELP(0)! "..recipe)
- print("OUTPUTTING data.raw")
- print(data.raw)
- print("OUTPUTTING data.raw.recipe")
- print(data.raw.recipe)
- print("OUTPUTTING data.raw.recipe[recipe] ")
- print(data.raw.recipe[recipe])
- print("OUTPUTTING bobmods ")
- print(bobmods)
- print("OUTPUTTING bobmods.lib ")
- print(bobmods.lib)
- print("OUTPUTTING bobmods.lib.item ")
- print(bobmods.lib.item)
- if not data.raw.recipe[recipe] then
- return false
- end
- if data.raw.recipe[recipe] and bobmods.lib.item.get_type(new) then
- print("HELP(1)! "..recipe)
- local amount = 0
- for i, ingredient in pairs(data.raw.recipe[recipe].ingredients) do
- if ingredient[1] == old then
- amount = ingredient[2] + amount
- end
- if ingredient.name == old then
- amount = ingredient.amount + amount
- end
- end
- if amount > 0 then
- bobmods.lib.recipe.remove_ingredient(recipe, old)
- bobmods.lib.recipe.add_ingredient(recipe, {new, amount})
- return true
- else
- return false
- end
- print("HELP(2)! "..recipe)
- else
- print("HELP(3)! "..recipe)
- if not data.raw.recipe[recipe] then
- log("Recipe " .. recipe .. " does not exist.")
- end
- print("HELP(4)! "..recipe)
- if not bobmods.lib.item.get_type(new) then
- log("Ingredient " .. new .. " does not exist.")
- end
- print("HELP(5)! "..recipe)
- return false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement