Advertisement
lavalevel

Basic Event Handler for Loop

Feb 7th, 2012
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. function handleturn()
  2. print("doing all the turn stuff here")
  3.  
  4. Runtime:dispatchEvent( "customevent", { type="handleTurn" } )
  5. end
  6.  
  7. function myEventHandler(event)
  8. if event.type == "handleTurn" then handleturn() end
  9. end
  10.  
  11. handleturn() -- trigger first time
  12.  
  13. Runtime:addEventListener("customevent", myEventHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement