How do you write a function that uses global variables? :) :)

I want to make a function that uses global variables to summon images but I always get an error

here is my code:

local function warrior (event)  
if getGlobal("Warrior") = 1  
then   
warrior = display.newImage('images/warrior.png',250,240)  
end  
end  
localGroup:insert( warrior )  

P.S. (I am using Director Class) [import]uid: 34097 topic_id: 16182 reply_id: 316182[/import]

If your global variable is Warrior,you can access this as

[lua]if _G.Warrior==1 then
–code
end[/lua] [import]uid: 64174 topic_id: 16182 reply_id: 60211[/import]

where it says local function warrior () what am i supposed to put between the parenthesis i get this error

Director ERROR: Failed to execute new( params ) function on ‘home’.

but it still shows my background but none of my buttons work. [import]uid: 34097 topic_id: 16182 reply_id: 60232[/import]

I use some globals & also use Director.

In main.lua (within the Main function), I declare a table & give it some defaults…

myGlobals = {}
myGlobals.test = “test”
myGlobals.number = 12
In any screen.lua file I can now read & write to these values.

hth [import]uid: 74250 topic_id: 16182 reply_id: 60434[/import]