Main.lua - Global Variables

How do you properly note your Global Variables in your main.lua file? I have two of them

_G.numberOne = numberFieldOne.text

_G.numberFive = numberFieldFive.text
I just didn’t know if you do local function or something and then where you locate in the file. This is my main now.

[lua]display.setStatusBar (display.HiddenStatusBar)
–> Hides the status bar

local director = require (“director”)
–> Imports director

local mainGroup = display.newGroup()
–> Creates a main group
local function main()
–> Adds main function

mainGroup:insert(director.directorView)
–> Adds the group from director

director:changeScene(“loadtitlescreen”)
–> Change the scene, no effects

return true
end

main()
–> Starts our app[/lua] [import]uid: 72372 topic_id: 13736 reply_id: 313736[/import]

I always do like this:
[lua]_G[“variablename”] = 0[/lua]

And in another file you call it the same way. It works just fine here! [import]uid: 75946 topic_id: 13736 reply_id: 50470[/import]

What is the zero for?

Also do you need to put it in a certain section in the main? [import]uid: 72372 topic_id: 13736 reply_id: 50471[/import]

you just need to write your _G. variable to main.lua and then access it in another .lua file the same _G.way [import]uid: 16142 topic_id: 13736 reply_id: 50473[/import]

Not that I know.

And the zero is just for example. You can create it in the main like that.
As you can put:

[lua]_G[“numberOne”]= 0[/lua]

and then on the other file you can put

[lua]_G[“numberOne”].text = numberFieldOne.text[/lua] [import]uid: 75946 topic_id: 13736 reply_id: 50474[/import]

Okay I don’t know if it’s working or not. Before I put the call out in my main it was doing what I wanted. I was told that I needed to do that though.

Michelle [import]uid: 72372 topic_id: 13736 reply_id: 50485[/import]