LabiVila Posted July 25, 2016 Share Posted July 25, 2016 Hello so my question is, how can I create another table and get returned that and not self? I'm a beginner in OOP and so far I've achieved somehow what I wanted with this: local players = {} local count = 0 function players:addPlayers (name, age) count = count + 1 local list = {} setmetatable (list, self) self [count] = {name = name, age = age} return self end function players:getAll () return self end addCommandHandler ("add", function (_, _, a, b) players:addPlayers (a, b) end ) addCommandHandler ("go", function () ai = players:getAll () for i,v in pairs (ai) do if (tonumber (i)) then outputChatBox (v.name.." "..v.age) end end end ) but If I loop through the self table, I get all function names (getPlayers, addPlayers and I don't know why) and I want a clear table for my players, not the 'self' one. thank you further Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now