From cc79b5fc03470ad4cc11d6bc73f786347a5d2261 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 19 Aug 2015 18:47:24 +0200 Subject: [PATCH] register a copy of the def instead of the passed def, this allows us later to spawn supporting nodes from the same original def --- homedecor/handlers/inventory.lua | 3 +-- homedecor/handlers/registration.lua | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/homedecor/handlers/inventory.lua b/homedecor/handlers/inventory.lua index 273497d..5855628 100644 --- a/homedecor/handlers/inventory.lua +++ b/homedecor/handlers/inventory.lua @@ -57,7 +57,7 @@ end -- locked = true, -- } -- -function homedecor.handle_inventory(name, def) +function homedecor.handle_inventory(name, def, original_def) local inventory = def.inventory if not inventory then return end def.inventory = nil @@ -153,6 +153,5 @@ function homedecor.handle_inventory(name, def) return allow_take and allow_take(pos, listname, index, stack, player) or stack:get_count() end - end end diff --git a/homedecor/handlers/registration.lua b/homedecor/handlers/registration.lua index cb5ad55..5e06e3c 100644 --- a/homedecor/handlers/registration.lua +++ b/homedecor/handlers/registration.lua @@ -2,7 +2,9 @@ homedecor = homedecor or {} local S = homedecor.gettext --wrapper around minetest.register_node that sets sane defaults and interprets some specialized settings -function homedecor.register(name, def) +function homedecor.register(name, original_def) + local def = table.copy(original_def) + def.drawtype = def.drawtype or (def.mesh and "mesh") or (def.node_box and "nodebox") @@ -19,7 +21,7 @@ function homedecor.register(name, def) def.paramtype2 = def.paramtype2 or "facedir" end - homedecor.handle_inventory(name, def) + homedecor.handle_inventory(name, def, original_def) local infotext = def.infotext --def.infotext = nil -- currently used to set locked refrigerator infotexts