Hello, I'm making a script sandbox and i want to know if there's any good way of copy a table and keep its metatables, i'm just leaving the table part, not the entire wrap function, here is the code:
function wrap(real)
local fake = {}
for i,v in next,real do
fake[i] = wrap(v)
end
return fake
end
Now i know that i can do this
function wrap(real)
local fake = {}
for i,v in next,real do
fake[i] = wrap(v)
end
fake = setmetatable(fake,getmetatable(real))
return fake
end
But if they lock the metatable i can not keep the metatables. In my other post someone said i can try to copy the behaviour of the metatable, but i don't know how i can do that. Help would be appreciated! :D

4 comments
take a look at http://lua-users.org/wiki/CopyTable
The problem is that the metatable can be locked with the __metatable metamethod
@kingdom5
fake setmetatable + remove __metatable field