Can I use print before os.exit?

How can I determine that the player exit my game?

I see in APIs this:

os.exit()

but how can I do an IF or FUNCTION that say to me that the player want to exit the game?

if os.exit then  
 print( "exit game" )  
end  
  

dont know, something like that :S
[import]uid: 23063 topic_id: 13260 reply_id: 313260[/import]

os.exit() quits the app immediately. You should never call this function. (There are a few rare cases where one might need this function.)

In the Sample Code, look at Hardware->SystemEvents for examples on how to listen for start/suspend/exit/resume events.
[import]uid: 7563 topic_id: 13260 reply_id: 48722[/import]

What I want to do is:
when player exit the game, my variable receives a value

playerExit = 0  
if os.exit then  
 playerExit = playerExit + 1  
end  
  

somethink like that
Can I do that?

EDIT:

got it

function onSystemEvent( event )   
 if "applicationExit" == event.type then  
 print ( "saiu do jogo" )  
 \_G.primeiraVez = 0  
 saveit2.save()  
 end  
end   
Runtime:addEventListener( "system", onSystemEvent )  

thank you for advice :smiley: [import]uid: 23063 topic_id: 13260 reply_id: 48725[/import]