So, I'm either not understanding the manual very well or it's not complete yet, but see how this goes.
If I add a registered event handler to a script, let's call it biggun, I can then raiseEvent(biggun, argument) inside of, say a trigger and it will then parse through that script.
There is also mention of doing something like myScript(event_name) but I don't really understand this example either. Is myScript the actual name of the script? Anyway, I hope my question comes across clearly and thanks in advance for the reply.
Registered Event Handlers
Re: Registered Event Handlers
script name:"onSmileEventHandler"
registered event handler list: "onSmile"
raiseEvent("onSmile") will call this script and any other scripts that have registred event handlers for "onSmile".
If your events contains additional arguments, the event handler functions needs to be declared correctly to be able to be called.
registered event handler list: "onSmile"
Code: Select all
function onSmileEventHandler( eventName )
echo("\nevent handler for event onSmile called!\n");
end
If your events contains additional arguments, the event handler functions needs to be declared correctly to be able to be called.
Re: Registered Event Handlers
You need to have a
function biggun (...)
In your script with such a registered handler
function biggun (...)
In your script with such a registered handler
Re: Registered Event Handlers
Just a note for future reference,
If you're passing arguments to an event handler (even more than one) you don't need ... as a parameter:
Then you can raiseEvent("myEvent", "wh", "a", "t") and have it printed to the screen. If you parse more than 4 parameters to raiseEvent the remainder get ignored (unless you use the arg table I guess). Note that the first argument for a handler is always the event name, if you don't need this (most of the time you wont), substitute it with a _ to save a little time. I.e;
function event( _, a, b, c)
...
If you're passing arguments to an event handler (even more than one) you don't need ... as a parameter:
Code: Select all
function event(eventName, a, b, c)
echo(a); echo(b); echo(c)
end
function event( _, a, b, c)
...