Sunwave
New Member
- Joined
- Dec 30, 2021
- Messages
- 3
- Reaction score
- 0
I'm working with metatables and I need help, I have a table inside this metatable and I wanted to insert values into them and return this table, but when I create the metatable these values are 0
Lua:
function Teste(cid)
local player = Player(cid)
if not player then
return
end
local t = {}
local init = {
insert = function(self, target)
table.insert(t, target)
end,
getTable = function(self)
return t
end
}
local meta = {
__index = init
}
return setmetatable({}, meta)
end
-- call metatable
if player then
local teste = Teste(player)
print(#teste:getTable()) -- value is 0
end