From c89484a676c2fe787bf55494eeed49611327ce86 Mon Sep 17 00:00:00 2001 From: Mernom <47146928+Mernom@users.noreply.github.com> Date: Thu, 15 Apr 2021 18:13:23 +0300 Subject: [PATCH] Added remove_ingredient to add_ingredient When adding ingredients, it WILL crash the game if duplicate entries exist, under most circumstances. The quick and dirty fix is to remove it before adding it, a more complicated check would involve looking for it and updating an existing entry instead. I just added the remove_ingredient so that the function is at least usable. --- stdlib/data/recipe.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/data/recipe.lua b/stdlib/data/recipe.lua index 51dd64ec..ea614217 100644 --- a/stdlib/data/recipe.lua +++ b/stdlib/data/recipe.lua @@ -100,7 +100,8 @@ end function Recipe:add_ingredient(normal, expensive) if self:is_valid() then normal, expensive = get_difficulties(normal, expensive) - + self:remove_ingredient (normal, expensive) + if self.normal then if normal then self.normal.ingredients = self.normal.ingredients or {}