_G Variable problem

Hi again ok I’m having a problem with global variable. I know people say stay away from it yeah I know but is there a way to control a global variable. Like unlocking levels using global var how do I control global var doing level unlock [import]uid: 17058 topic_id: 20284 reply_id: 320284[/import]

why do you want to use globals to unlock levels? just save and load table
global vars will be useful just inside app, next run they will reset, no point in them [import]uid: 16142 topic_id: 20284 reply_id: 79267[/import]

Can you show me how to check that someone beat that and then save it. All the levels are never locked there always unlocked. [import]uid: 17058 topic_id: 20284 reply_id: 79269[/import]

I use ICE to achieve the same. Very easy …

Its explained here http://developer.anscamobile.com/code/ice [import]uid: 103970 topic_id: 20284 reply_id: 79281[/import]

can @mygamingproject you show me an example of using ice for checking that a level is won or anybody volunteer I get lots of help but somehow especially for how to save and I hope the last people that helped me don’t get offended your help is awesome especially peach. I’m just asking other people If they have other alternatives way to do it. [import]uid: 17058 topic_id: 20284 reply_id: 79293[/import]

In your game design what determines that a level should be unlocked? [import]uid: 103970 topic_id: 20284 reply_id: 79362[/import]

An example of how it could work

[lua]require( “ice” )

– initialise your best score

scores = ice:loadBox( “scores” )
scores:storeIfNew( “best”, 0 )
scores:save()

– initialise your score to be used in game
myscore = scores:retrieve( “best” )

– Then do a simple conditional to see if the score is big enough to make level available

if(myscore > 1000) then
– make level 1 available
end
if(myscore > 5000) then
– make level 2 available
end

– Presumably you would have some local score being incremented
myscore =

– Later in your game update your score back to ice so its remembered on next load
scores:storeIfHigher(“best”, myscore)
scores:save()[/lua]

You would need to optimise the code but gives you an idea of how to save and retrieve scores from tables as @darkconsoles originally suggested but in just a few lines of code using ICE
[import]uid: 103970 topic_id: 20284 reply_id: 79364[/import]