Thread: [Tutorial] Random questions thread
View Single Post
Old 04-15-2012, 11:55 AM   #121   Add To Ignore List  
Mischievous's Avatar
Joined: Aug 2009
Location: I'm a gamer, so in a metaphysical way,no where.
Mischievous is offline
Default Re: Random questions thread

A RunHandled function is pretty much used for more complex situations, where you want to watch for many events simultaneously and/or have more than one thread of code running at the same time. It is usually constructed of a handler function, first parameter, and handlers for that function. A RunHandled block ceases execution when the handler function reaches its 'end'.

Here's a simple handler function that will spawn enemies every 8 seconds, and different enemies every 6 seconds. That would be harder to do with a simple "Wait(Event(...))" construction, and in some cases almost impossible.

  function() -- handled function
    WaitForever() -- this will make the RunHandled function run forever, since WaitForever() prevents it from reaching it's end.
  end, -- note the comma operator(,) after end!

  On(Delay(10)), -- handler 1

  On(Delay(15)), -- handler 2
    end -- note the lack of a comma operator(,) after end!
A RunHandled function must always have one handled function, and at least one handler to work.
Secretly Blue
Mass Effect 3, It's kind of as if you had to pay extra to see Golum in the LOTR series.
Louva-Deus:"You were born with a longer tail that the rest of us"
  Reply With Quote