Saving values

I need help understanding how to save a value when you exit a lua file ( or switch to a different one), and I need to acces that value from a different lua file.

I also need help in saving high scores. I read an article on techority.com, but I still don’t understand how to do it [import]uid: 104376 topic_id: 22216 reply_id: 322216[/import]

Hi.

Try ICE : http://developer.anscamobile.com/code/ice

It makes doing all of this very easy :slight_smile: [import]uid: 84637 topic_id: 22216 reply_id: 88483[/import]

I took a look at it, and I noticed that there is no explanation on how to use it I probably will be using a more common method that is explained more.

Sooo any other ideas? [import]uid: 104376 topic_id: 22216 reply_id: 88516[/import]

are you using director if so you can pass values though director

js.lua in the code exchange offers a way to manage high scores and a way of saving info to file [import]uid: 7911 topic_id: 22216 reply_id: 88519[/import]

yes i am using director. how do I pass values through it? can I just write something like

gameIsActive = true

instead of

local gameIsActive = true
and I would be able to access that value from another file?

and for js.lua I’ll take a look [import]uid: 104376 topic_id: 22216 reply_id: 88520[/import]

its been awhile since i did it so give me a few or maybe someone else here know [import]uid: 7911 topic_id: 22216 reply_id: 88524[/import]

alright. As for js.lua I have a question. Do you have to save tables, or can you just save values.
e.g.

[lua]local fileKey = {gameIsActive = true,
lv1IsActive = false,
lvl2IsActive = true }
js.fileInit( “game.dat”, fileKey ) [import]uid: 104376 topic_id: 22216 reply_id: 88528[/import]

director:changeScene( params, newScene, effect )

[import]uid: 7911 topic_id: 22216 reply_id: 88529[/import]

http://developer.anscamobile.com/forum/2012/02/15/passing-variablesproperties-how-hard-can-it-be [import]uid: 10389 topic_id: 22216 reply_id: 88530[/import]

@jstrahan that is for switching files
@Waulok that is just what i was looking for thanks! [import]uid: 104376 topic_id: 22216 reply_id: 88531[/import]

it needs to be set up like this

  
local fileKey = { gameData = { gameIsActive,true, lv1IsActive, false, lv2IsActive, true }  
  

im in the process of writing a new save module that will be a lot easier to use but may be a while before its ready im working on some updates to some of my other modules
[import]uid: 7911 topic_id: 22216 reply_id: 88532[/import]

I could change “gameData” to anything right?

and then if I want a function like
[lua]local function example(event)
if lvl1IsActive = true then
–perform an event
end
end[/lua]

do I need to change lvl1IsActive to something else? (I have never done tables before) [import]uid: 104376 topic_id: 22216 reply_id: 88536[/import]

yes you can change gameData to anything

when you read the values you would do
if gameData.lv1IsActive == true
or whatever you change gameData to [import]uid: 7911 topic_id: 22216 reply_id: 88539[/import]

And when do I need to load the file (in every lua or just in main)

I need to use
game = js.fileLoad( “game.dat” )

as far as I know
Can i change “game” to anything?

[import]uid: 104376 topic_id: 22216 reply_id: 88540[/import]

Stieven.ua

Did you not see the samples included in the lime page i linked you to ? [import]uid: 84637 topic_id: 22216 reply_id: 88630[/import]