Access variables and call functions between main.lua and its scenes?

I’m aware that I can create variables within the composer, however I’m wondering if there’s any other ways to access variables from different scenes/main.

I also have no idea how to call the functions defined in main from a scene and vice-versa.

EXAMPLE:

Main.lua----------------------------------------------------------------------------

local text1 = display.newText( “lolololol” )

local words1 = “lolz”

Scene1.lua-------------------------------------------------------------------------

local button1Press = function( event )

   text1.text = words1

end

Hi @n5tran,

This tutorial explains an alternative method of handling “global” (but not truly Lua global) variables:

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

Best regards

Brent

I don’t get this…

Just getting started on Corona/Lua and variables, declarations, etc, seem to be a mess!!

As soon as I put a variable in a different file and try to access it EXACTLY as per the above tutorial all I get is:

Attempt to index local…blah blah blah.

This should be easy. Both files in same location. What am I missing? Thanks in advance…

Hi @n5tran,

This tutorial explains an alternative method of handling “global” (but not truly Lua global) variables:

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

Best regards

Brent

I don’t get this…

Just getting started on Corona/Lua and variables, declarations, etc, seem to be a mess!!

As soon as I put a variable in a different file and try to access it EXACTLY as per the above tutorial all I get is:

Attempt to index local…blah blah blah.

This should be easy. Both files in same location. What am I missing? Thanks in advance…