How change value of variables in another scene ?

How can i change variable value of a scene different ?

Exemple : I’m in scene X and I went change the value of variable in scene Y

You should make the variable pass from one scene to another. A good way to do it is to add a variable in the main.lua like this:
 

storyboard.yourTable = {} storyboard.yourTable.yourValue = something

By doing it you pass the variable to all the scenes using the storyboard.

Hmm … I use library director … This also works in it?

And another question, I have to set a value to the variable so I can use it, but if I set “0” when I open the game again, the variable back to 0, how can I solve this?

you can require the certain scene in another scene and use the variables from the scene you required.

local view1 = require "view1" view1.value = view1.value - 1

You can overcome this by declaring something like variable = get saved data or 0.
I don’t know what method you use for saving data but you can simply declare that the variable is either the saved data or 0. If it is the first time when the game is opened your saved data would be nil so the value would be 0. Than when you save some progress the variable will this saved value. 
Also you can do it via condition. For instance:

if get your saved data == nil then variable =0 else variable = get your saved data end

What I put in “your saved data”? And how do I save the data?

This tutorial might help:  http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

Rob

You may also try the GGData library
It’s very easy to use
https://developer.coronalabs.com/code/ggdata

Oh my god! 

I got it, thanks guys, after a time solving some bugs I finally managed to do this, thank you so much Patso, without you I would not have gotten, and thanks for the help Rob

*-----------*

You should make the variable pass from one scene to another. A good way to do it is to add a variable in the main.lua like this:
 

storyboard.yourTable = {} storyboard.yourTable.yourValue = something

By doing it you pass the variable to all the scenes using the storyboard.

Hmm … I use library director … This also works in it?

And another question, I have to set a value to the variable so I can use it, but if I set “0” when I open the game again, the variable back to 0, how can I solve this?

you can require the certain scene in another scene and use the variables from the scene you required.

local view1 = require "view1" view1.value = view1.value - 1

You can overcome this by declaring something like variable = get saved data or 0.
I don’t know what method you use for saving data but you can simply declare that the variable is either the saved data or 0. If it is the first time when the game is opened your saved data would be nil so the value would be 0. Than when you save some progress the variable will this saved value. 
Also you can do it via condition. For instance:

if get your saved data == nil then variable =0 else variable = get your saved data end

What I put in “your saved data”? And how do I save the data?

This tutorial might help:  http://coronalabs.com/blog/2013/05/28/tutorial-goodbye-globals/

Rob

You may also try the GGData library
It’s very easy to use
https://developer.coronalabs.com/code/ggdata

Oh my god! 

I got it, thanks guys, after a time solving some bugs I finally managed to do this, thank you so much Patso, without you I would not have gotten, and thanks for the help Rob

*-----------*