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:

1
2
3
4
5
6
7
8
9
local function warrior (event)
if getGlobal("Warrior") = 1
then 
warrior = display.newImage('images/warrior.png',250,240)
end
end
 
 
localGroup:insert( warrior )

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

1
2
3
if _G.Warrior==1 then 
   --code
end

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.

views:1276 update:2011/10/19 8:59:29
corona forums © 2003-2011