RunCallback(func[, userdata])
func to the event queue. The function will
be run the next time Hollywood checks the event queue, i.e. when CheckEvent()
or WaitEvent() gets called.
The optional userdata argument allows you to specify additional data that will be passed to
your callback function whenever it is called. This is useful if you want to avoid working with
global variables. Using the userdata argument you can easily pass data to your callback
function. You can specify a value of any type in userdata. Numbers, strings, tables, and even
functions can be passed as user data.
Your callback function will be called by Hollywood with a single parameter. The parameter is a message table which contains the following fields:
Action:RunCallback. This field is a string!
UserData:userdata argument when calling RunCallback().
Note that this field will only be there if you have actually passed a value in userdata
when calling RunCallback().
RunCallback(Function(msg) NPrint(msg.userdata) EndFunction, "Hello 2!")
NPrint("Hello 1!")
Repeat
WaitEvent
Forever
This will first print "Hello 1!" and then "Hello 2!" because the
function that prints "Hello 2!" won't be called until Hollywood empties
the event queue which happens on WaitEvent().