Posted 12 February 2013 - 01:46 PM
I recently learned basics about metatables in lua.
My problem is that i can only insert a metatable into anotherone
with it's metatable.
I hope the example can show my problem better:
therefore t[1].test returns "test".
now, if i change s:
t[1].test also returns "asdf".
Is there a way to prevent that instead of changing these to normal tables?
(I need both of them as metatables for the rest of my apis)
thanks. :)/>/>
Edit: This means that i need a method like getmetatable to get back the table that has the metatable attached to it (if such a method exists)
My problem is that i can only insert a metatable into anotherone
with it's metatable.
I hope the example can show my problem better:
t = {}
t = setmetatable({}, t)
s = {}
s = setmetatable({test = "test"}, s)
table.insert(t, s)
therefore t[1].test returns "test".
now, if i change s:
s.test = "asdf"
t[1].test also returns "asdf".
Is there a way to prevent that instead of changing these to normal tables?
(I need both of them as metatables for the rest of my apis)
thanks. :)/>/>
Edit: This means that i need a method like getmetatable to get back the table that has the metatable attached to it (if such a method exists)