Apologies - this is another lua question really rather than Gideros but hopefully someone can suggest a good solution.
I have an array of Buttons and I would like to move a button from one array position to another.
I was making the second array position equal to the first and then setting the first array position to nil - but of course I soon realised that I need to actually perform a proper deep copy of the Button otherwise the second array position is only pointing at the Button in the first array position.
Given that my button class has all sorts of properties - do I have to write a custom method to perform a deep copy of a class instance or is there something built into Lua that can create a proper copy?
Many thanks
Comments
The function will then create a new instance of the current button (self) and then initialise it to have the same values as the current button, you then return this new button as the result of the clone / copy function.
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
But if you need to copy, then it would depend on structure of your button, there is no standard function to do it.
Here is an example for tables, which I think should also work for classes:
http://stackoverflow.com/questions/640642/how-do-you-copy-a-lua-table-by-value