From 4d73d3fdf295361a2d5ab004ffe5108429216140 Mon Sep 17 00:00:00 2001 From: Niklp09 <89982526+Niklp09@users.noreply.github.com> Date: Wed, 4 Jan 2023 13:38:08 +0100 Subject: [PATCH] glowlight: register flowers only once --- lamps/growlight.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lamps/growlight.lua b/lamps/growlight.lua index f4b1ac3..25059ce 100644 --- a/lamps/growlight.lua +++ b/lamps/growlight.lua @@ -171,11 +171,26 @@ minetest.register_craft({ }, }) +local function contains(table, element) + for _, value in pairs(table) do + if value == element then + return true + end + end + return false +end + function techage.register_flower(name) + if contains(Flowers, name) then + return + end Flowers[#Flowers+1] = name end function techage.register_plant(name) + if contains(Plants, name) then + return + end Plants[name] = true end @@ -201,4 +216,5 @@ minetest.after(1, function() end end end + print(dump(Flowers)) end)