Hello,
I’m trying to use Peach Pellen’s Save/Load Data Tutorial Code to implement my own system of Locking/Unlocking levels. However I keep getting the following error.
Project/Version1/levelselect.lua:142: attempt to perform arithmetic on field ‘twolock’ (a nil value)
I tried everything I could possibly think of and then out of curiosity, I copied the tutorial code into my file exactly as Peach had it. I still got the error. The only difference between the example and mine, is that the example Peach gave went main.lua --> menu.lua. My project goes main.lua–> menu.lua–> modeselect.lua–> levelselect.lua. All the code for saving data is inside levelselect.lua for me while it is inside menu.lua in Peach’s example. Does that make a difference? Line 2 below is the line that the error is referencing to. Any help on this would be appreciated.
[blockcode]local function seticontwo (event)
if _G.twolock-0 == 0 then
local leveltwoicon = display.newImageRect (“images/levelblocks/level2locked.png”, 45, 43)
leveltwoicon.x = 130
leveltwoicon.y = 40
localGroup:insert(leveltwoicon)
elseif _G.twolock-0 == 1 then
local leveltwoicon = display.newImageRect (“images/levelblocks/level2.png”, 45, 43)
leveltwoicon.x = 130
leveltwoicon.y = 40
localGroup:insert(leveltwoicon)
leveltwoicon:addEventListener(“tap”, gototwo)
end
end
seticontwo()
[/blockcode]
Thanks. [import]uid: 47722 topic_id: 13715 reply_id: 313715[/import]

