From adf04af6e865caf985afb83f6080ea88dd7bd858 Mon Sep 17 00:00:00 2001 From: Thomas--S Date: Sat, 22 Aug 2020 12:06:32 +0200 Subject: [PATCH] Growlight: Improve flower registration - Avoid duplicate registrations - Add support for Bakedclay flowers --- lamps/growlight.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lamps/growlight.lua b/lamps/growlight.lua index 8d35369..6938f99 100644 --- a/lamps/growlight.lua +++ b/lamps/growlight.lua @@ -138,10 +138,11 @@ function techage.register_plant(name) end minetest.after(1, function() - for name,_ in pairs(minetest.registered_decorations) do - if type(name) == "string" then + for _,def in pairs(minetest.registered_decorations) do + local name = def.decoration + if name and type(name) == "string" then local mod = string.split(name, ":")[1] - if mod == "flowers" then + if mod == "flowers" or mod == "bakedclay" then -- Bakedclay also registers flowers as decoration. techage.register_flower(name) end end @@ -149,12 +150,8 @@ minetest.after(1, function() for name,ndef in pairs(minetest.registered_nodes) do if type(name) == "string" then local mod = string.split(name, ":")[1] - if mod == "farming" then - if ndef.on_timer then -- probably a plant that still needs to grow - techage.register_plant(name) - end - elseif mod == "flowers" then - techage.register_flower(name) + if mod == "farming" and ndef.on_timer then -- probably a plant that still needs to grow + techage.register_plant(name) end end end