Copytable loses Function, Bug or Behavior?
Posted: Fri Oct 11, 2024 2:34 pm
Here are two basically similar situations, one works, other doesn't:
This first one works fine and debugprints the "text to print"
I am not going to copy my whole program, but just point out these three lines which show what happens:
Practically line 1 and 3 are identical, both are calling this DrawTopCard() function, however, the line 3 fails saying "Function drawtopcard() not found!"
Why did this first example not lose the function, while the second one did, even they seem identical? Also, is this a bug or a feature?
Code: Select all
TableModel = { text="text to print"}
Function TableModel:New()
Local o = TableModel
SetMetaTable(o, {__index = TableModel})
Return(o)
EndFunction
Function TableModel:MyPrintFunction()
DebugPrint(self.text)
EndFunction
NewTable = {}
NewTable[1] = {}
NewTable[1].ThisTable = TableModel:New()
CopyOfNewTable = CopyTable(NewTable)
CopyOfNewTable[1].ThisTable:MyPrintFunction()I am not going to copy my whole program, but just point out these three lines which show what happens:
Code: Select all
T_Teams[1].Deck:DrawTopCard()
T_TempTeams = CopyTable(T_Teams)
T_TempTeams[1].Deck:DrawTopCard()
Why did this first example not lose the function, while the second one did, even they seem identical? Also, is this a bug or a feature?