Setting up a function that uses global variable to display image :)

I made a global variable that looks like this:

\_G.warrior = 0 I put this in Main.lua

I am using director class and i have a different scene where there is a button to make _G.warrior = 1 :

  
local warriorButton = display.newImage('images/warriorButton.png')  
 warriorButton.x = 675  
 warriorButton.y = 100  
  
localGroup:insert( warriorButton )  
  
local function pressWarrior (event)  
if event.phase == "ended" then  
\_G.warrior = 1  
  
end  
end  
  
warriorButton:addEventListener ("touch", pressWarrior)  
  

and so i want to make a function that links these together this is what i have so far:

function summonWarrior ( event )
if _G.warrior = 1 then
local warrior = display.newImage(‘images/warrior.png’)
warrior.x = 480
warrior.y = 480

localGroup:insert( warrior )
end
THNX before Hand :))) [import]uid: 34097 topic_id: 16087 reply_id: 316087[/import]

It looks fine. so whats the problem you are facing ? [import]uid: 71210 topic_id: 16087 reply_id: 59835[/import]

Its not showing up the picture is not there, can you tell me how to make it greater than or equal to 1 [import]uid: 34097 topic_id: 16087 reply_id: 59869[/import]

just a quick check…
have you given _G.warrior = 1 or _G.warrior == 1 in where condition ?
to see whether the value is being set try printing _G.warrior before the if condition.
print(_G.warrior) and check the console for output. [import]uid: 71210 topic_id: 16087 reply_id: 59877[/import]