Let me do a quick explanation of what is wrong, because if I really want to tell you how lua classes work I'll be typing for hours.
First of all, when you're assigning the 'class' you just create a pointer (in C-terms), so all you do is creating a reference to the table instead of cloning it. To clone it there are several ways, first: loop over all indexes and assign their values to the same indexes in the new table, second way: use __index in a metatable, this makes sure that missing keys of the table are looked up in the original table, but when you change them new ones are created.
Next, you need to start working with the self variable, example:
Code: Select all
someTable = {}
someTable.value = 3
function someTable:someFunction() --this is the same as someTable.someFunction(self) (difference is : )
self.value = 20
end
someTable:someFunction()
--someTable.value is now 20, without the function ever knowing it's name, so if it was located in another table it would've set the variable in that table.
I hope this is enough to get you started, because I don't feel like typing a lot.