From b483733540177acae765d0668202da03a91f899d Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sun, 27 Oct 2013 22:51:56 -0400 Subject: [PATCH] Move table copy function out of signs lib and into init.lua, make it global. --- doors_and_gates.lua | 2 +- init.lua | 18 ++++++++++++++++++ signs_lib.lua | 16 ++-------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/doors_and_gates.lua b/doors_and_gates.lua index 0f57df29..3bb85426 100644 --- a/doors_and_gates.lua +++ b/doors_and_gates.lua @@ -373,7 +373,7 @@ for i in ipairs(gates_list) do minetest.register_node("homedecor:gate_"..gate.."_closed", def) -- this is either a terrible idea or a great one - def = table.copy(def) + def = homedecor.table_copy(def) def.groups.not_in_creative_inventory = 1 def.selection_box.fixed = { 0.4, -0.5, -0.5, 0.5, 0.5, 0.5 } def.tiles = { diff --git a/init.lua b/init.lua index f9497d02..c0a5ca47 100644 --- a/init.lua +++ b/init.lua @@ -29,18 +29,36 @@ else end homedecor.gettext = S +-- debug + local dbg = function(s) if homedecor.debug == 1 then print('[HomeDecor] ' .. s) end end +-- infinite stacks + if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then homedecor.expect_infinite_stacks = false else homedecor.expect_infinite_stacks = true end +--table copy + +function homedecor.table_copy(t) + local nt = { }; + for k, v in pairs(t) do + if type(v) == "table" then + nt[k] = homedecor.table_copy(v) + else + nt[k] = v + end + end + return nt +end + dofile(homedecor.modpath.."/ownership.lua") dofile(homedecor.modpath.."/lib_6d.lua") diff --git a/signs_lib.lua b/signs_lib.lua index 9c4b449b..38dc47fe 100644 --- a/signs_lib.lua +++ b/signs_lib.lua @@ -288,18 +288,6 @@ local function make_line_texture(line, lineno) return table.concat(texture, ""), lineno end -local function copy ( t ) - local nt = { }; - for k, v in pairs(t) do - if type(v) == "table" then - nt[k] = copy(v) - else - nt[k] = v - end - end - return nt -end - local function make_sign_texture(lines) local texture = { ("[combine:%dx%d"):format(SIGN_WIDTH, LINE_HEIGHT * NUMBER_OF_LINES * LINE_SEP) } local lineno = 0 @@ -594,8 +582,8 @@ function homedecor.register_fence_with_sign(fencename, fencewithsignname) minetest.log("warning", "[homedecor] Attempt to register unknown node as fence") return end - def = copy(def) - def_sign = copy(def_sign) + def = homedecor.table_copy(def) + def_sign = homedecor.table_copy(def_sign) fences_with_sign[fencename] = fencewithsignname def.on_place = function(itemstack, placer, pointed_thing, ...)