Hi,
When I run table.copy to many times in a for loop it crashes in one part but not in another. Explanation with code:
when turns, in the for loop is set to 1 or 2 it runs okay but when I increase it to even as little as 5 it crashes. The strange thing is if I move the first three rows (local h1, h2 and b table.copy) outside the loop it works even though I have more table copies below.
The idea is that in h1, h2 and b I have original value from the user and then the app fills up/randomizes the rest of the table so I need them to be their own values (not reference types).
for yCount = 1, turns, 1 do local h1 = table.copy(hand1) local h2 = table.copy(hand2) local b = table.copy(board) h1,h2,b = randomizeCards(h1,h2,b) -- Player1 hands local player1Value local hands = {} hands[1] = table.copy(h1) h1[6] = b[1] hands[2] = table.copy(h1) h1[6] = b[2] hands[3] = table.copy(h1) h1[6] = b[3] hands[4] = table.copy(h1) end
I have also tried using the shallowcopy and deepcopy function from the LUA page.
The tables are small and contains 5 records and that’s it.
Can somebody help me with this?
Best regards,
Tomas