Save a number after changeScene

Hi, I'm looking for a possibly simple way to save a number. I have three buttons: A count up button, A count down button, and a button that changes the scene to a different .lua file. When I input a number using the first two buttons, and then change the scene, the number imputed will reset. How can I save the number? Any help is greatly appreciated.

do you just want to save the number for a single game session ? then you may use a global variable.

you can use it with the global name space

1
_G.number = yournumber

Thanks for the reply. I was hoping to be able to save the number until the app is closed. My 'Number' is actually my text + 1. Will the _G still apply?

1
2
3
4
5
6
function plus(event)
if event.phase == "ended" then
holScr.text = holScr.text + 1
 
end
end<code>

Global variable can hold any value just like local variable.

I'm sorry, but I'm a noob, and I don't entirety follow. With this _G, I can cause a .lua file to retain its state even after I reload the app, or change the scene to another .lua file?

views:1331 update:2011/10/11 15:24:38
corona forums © 2003-2011