Prevent duplicate entries when adding a recipe to a technology

This commit is contained in:
Simon Brodtmann 2025-02-02 17:18:54 +01:00
parent 75429369d1
commit dca2bd9129

View file

@ -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