Game Timer

I am making a game that will let you eat food. It is really simple. But I want to find out how to make a timer. It is were you would have a game timer so 10 9 8 7 6 5 4 3 2 1 0. And when the timer hits 0 I want it to check the score, so score = 10 and scoreText.text stuff like that. So How would I make a if statement to check the score and then a else for if it is not at the needed score [import]uid: 55737 topic_id: 11397 reply_id: 311397[/import]

Try This:

local textObject = display.newText("",150,20,native.systemFontBold,24)  
textObject:setTextColor(0,0,0)  
textObject.x = display.contentWidth/2  
textObject.y = display.contentHeight/2  
local gameTime=10  
local timeCheck = {}  
function timeCheck:timer( event )  
gameTime=gameTime-1  
textObject.text = "Time Left:" ..gameTime  
if ( gameTime == 0 ) then  
timer.cancel(t2)  
pausebutton.x = 25  
if score \>= 10 then  
textObject.text = "You made it!"  
else  
textObject.text = "Your score wasn't high enough!"  
end  
-- other end of game functions here  
end  
end  
  
-- start timer  
t2 =timer.performWithDelay(1000, timeCheck, 0)  

That should do the trick. Don’t forget that your ‘score’ variable should be declared before this function. [import]uid: 38001 topic_id: 11397 reply_id: 41294[/import]