From 1b54011b6813eeacf6e2c8c0ba61680b66d9ab45 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sat, 21 Sep 2019 21:09:46 +0000 Subject: [PATCH] Use table.copy in mesecons.tablecopy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mesecons.tablecopy didn’t support recursive tables, while Minetest table.copy works well for them. --- mesecons/util.lua | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/mesecons/util.lua b/mesecons/util.lua index b15858d..7485cac 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -186,19 +186,11 @@ function mesecon.invertRule(r) return vector.multiply(r, -1) end -function mesecon.tablecopy(table) -- deep table copy - if type(table) ~= "table" then return table end -- no need to copy - local newtable = {} - - for idx, item in pairs(table) do - if type(item) == "table" then - newtable[idx] = mesecon.tablecopy(item) - else - newtable[idx] = item - end +function mesecon.tablecopy(obj) -- deep copy + if type(obj) == "table" then + return table.copy(obj) end - - return newtable + return obj end function mesecon.cmpAny(t1, t2)