Hey sorry to bother again, hoping you can shed some light on a issue im having. So in my game, i am creating a table and recording movement that the player makes, and at the end of the level im saving the table using the “ice” module. when i am leaving the level and doing clean up, i am doing what you suggested above to remove the table, which seems to work fine. But then when i return to replay the same level, it finds the table as nil. Now this only occurs when i return immediately to the same level, if i quit out, or play another level and go back to the previous, then my code is able to find the saved table information.
Its like my code isnt creating a new table if i do immediate replay. Anyways not sure if you would have any clue of what might be going on there. here is a bit of code.
[lua]local ghostTableTempX = {}
local ghostTableTempY = {}
local ghostTableX = {}
local ghostTableY = {}
–These two lines retrieve the saved “ghost” data from a table i save the first time you play a level
ghostTableX = global.tireData:retrieve(“level”…levelNumber…“GhostX”)
ghostTableY = global.tireData:retrieve(“level”…levelNumber…“GhostY”)
–I use this at the end of my level to store the table that holds the movements
global.tireData:store( “level”…levelNumber…“GhostX”, ghostTableTempX )
global.tireData:store( “level”…levelNumber…“GhostY”, ghostTableTempY )
global.tireData:save()
–Destroy ghost tables (i call this when im cleaning up a level)
for i = #ghostTableTempX, 1, -1 do
table.remove(ghostTableTempX, i)
end
ghostTableTempX = nil
for i = #ghostTableTempY, 1, -1 do
table.remove(ghostTableTempY, i)
end
ghostTableTempY = nil
if wasGhostOpen == true then
for i = #ghostTableX, 1, -1 do
table.remove(ghostTableX, i)
print(i)
end
ghostTableX = nil
for i = #ghostTableY, 1, -1 do
table.remove(ghostTableY, i)
end
ghostTableY = nil
end
–These functions record movement and play them back
frameStepRecord = 1
local trackGhost = function()
if isGhostRecord == true then
ghostTableTempX[frameStepRecord] = M.tireObject.x
ghostTableTempY[frameStepRecord] = M.tireObject.y
frameStepRecord = frameStepRecord + 1
end
end
frameStepPlay = 1
local playGhost = function()
if ghostActive == true and ghostRun == true then
if frameStepPlay == ghostEndPoint then
ghostRun = false
end
ghostTire.x = ghostTableX[frameStepPlay]
ghostTire.y = ghostTableY[frameStepPlay]
frameStepPlay = frameStepPlay + 1
end
end[/lua]
So basically when i replay the same current level im on then it says ghostTableX and ghostTableY are nil values, but if i go back to the main menu of my game, load up that same level again, the first run it will play back the data just fine, do replay, and those are shown as nil values again. [import]uid: 19620 topic_id: 19677 reply_id: 77105[/import]