mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-08-20 13:04:10 +02:00
Use table.copy in mesecons.tablecopy
mesecons.tablecopy didn’t support recursive tables, while Minetest table.copy works well for them.
This commit is contained in:
parent
15e743629e
commit
1b54011b68
@ -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
|
||||
function mesecon.tablecopy(obj) -- deep copy
|
||||
if type(obj) == "table" then
|
||||
return table.copy(obj)
|
||||
end
|
||||
end
|
||||
|
||||
return newtable
|
||||
return obj
|
||||
end
|
||||
|
||||
function mesecon.cmpAny(t1, t2)
|
||||
|
Loading…
Reference in New Issue
Block a user