From dca2bd9129eace4d4dbdbdf6397eb19ad263ac85 Mon Sep 17 00:00:00 2001 From: Simon Brodtmann Date: Sun, 2 Feb 2025 17:18:54 +0100 Subject: [PATCH] Prevent duplicate entries when adding a recipe to a technology --- cf-lib/data/Technology.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cf-lib/data/Technology.lua b/cf-lib/data/Technology.lua index d1d1dbb..d6d82f1 100644 --- a/cf-lib/data/Technology.lua +++ b/cf-lib/data/Technology.lua @@ -132,6 +132,11 @@ end --- Adds a recipe unlock to the technology --- @param recipeName string The name of the recipe to unlock function Technology:addRecipe(recipeName) + for _, effect in pairs(self.prototype.effects) do + if effect.type == "unlock-recipe" and effect.recipe == recipeName then + return + end + end table.insert(self.prototype.effects, { type = "unlock-recipe", recipe = recipeName }) end