diff --git a/cf-lib/data/Recipe.lua b/cf-lib/data/Recipe.lua index 6eca2b6..01358d5 100644 --- a/cf-lib/data/Recipe.lua +++ b/cf-lib/data/Recipe.lua @@ -102,9 +102,9 @@ end --- @param ingredientName string The name of the ingredient function Recipe:removeIngredient(ingredientName) if self.prototype.ingredients then - for i, result in pairs(self.prototype.ingredients) do - if result.name == ingredientName then - self.prototype.ingredients[i] = nil + for i, ingredient in pairs(self.prototype.ingredients) do + if ingredient.name == ingredientName then + table.remove(self.prototype.ingredients, i) return self end end @@ -137,6 +137,20 @@ function Recipe:replaceResult(old, new, amount, expensiveAmount) return self end +--- Removes an existing result by name +--- @param resultName string The name of the result +function Recipe:removeResult(resultName) + if self.prototype.results then + for i, result in pairs(self.prototype.results) do + if result.name == resultName then + table.remove(self.prototype.results, i) + return self + end + end + end + return self +end + --- Adds the recipe to a technology --- @param technology string|table The name of the technology or the technology table function Recipe:unlockedByTechnology(technology)