Difference between revisions of "SetEventHandler"
Jump to navigation
Jump to search
m
no edit summary
imported>8asrun6aer m (→Notes) |
imported>8asrun6aer m |
||
|
(success:bool) SetEventHandler eventID:string functionScript:ref filter1:pair filter2:pair
Registers a user-defined function script as a handler for the specified event. If the user-defined function script returns a value, it will be ignored
Two optional arguments can be supplied to '''SetEventHandler''' by using the unique syntax of ''"key"''::''value'' pairs to filter events according to the target and/or object. The ''"key"'' part is a string (must be enclosed in quotes) and is generally expected to be either "ref" (generally referring to the target or first argument in your custom function) or "object" (generally referring to the source or second argument in your custom function), regardless of the names of the argument variables in your function script (exception: for OnHealthDamage, "object" refers to the damaged actor).
For more details on events and for a list of available events to hook into, see [[Event_Handler_Functions]].▼
▲For more details on events and for a list of available events to hook into, see [[
== Example ==
begin gamemode
if getGameRestarted
SetEventHandler "OnHit" FnOnHitByPlayer "object"::
SetEventHandler "OnMagicEffectHit" FnOnPlayerRestoreHealth "ref"::
SetEventHandler "LoadGame" FnOnLoadGame
endif
</pre>
With the the above four scripts compiled and loaded and the quest script ''SomeQuestScript'' activated, you should then see the following new effects in game:
# Whenever the player hits another actor, that actor will be knocked back 50 feet/units.
# Whenever the "REHE" magic effect is applied to the player, you should see a message: "The player has been hit by a restore health effect"
# Whenever a game is loaded, you should see a console message: "Loading game from ''filename''"
==Notes==
'''none'''
| |||