Mod:Creation Kit/RegisterForCustomEvent - ScriptObject

Member of: Mod:Creation Kit/Mod:Creation Kit/ScriptObject Script

Registers this script to receive the specified custom event from the source object whenever that source object sends the event. The event will be relayed only to this script and will not be sent to other scripts attached to the same object, or to any aliases or magic effects attached to the object.

Syntax
Function RegisterForCustomEvent(ScriptObject akSender, CustomEventName asEventName) native

Parameters

 * akSender: The ScriptObject that receives the event we want to also receive.
 * asEventName: The event we want relayed to us. This must be a raw string literal and may not be a variable.

Return Value
None

Examples
AmbushTriggerScript Property kTrigger Auto Const
 * AmbushTriggerScript defines the Ambush custom event

Event OnInit ; Register for Ambush event from the trigger - note the trigger type is the script type that defines the event RegisterForCustomEvent(kTrigger, "Ambush") EndEvent

Event AmbushTriggerScript.Ambush(AmbushTriggerScript akSender, Var[] akArgs) Debug.Trace("We received the ambush event from " + akSender + " with arguments " + akArgs) EndEvent
 * Special event to receive when the ambush event is received from a AmbushTriggerScript script
 * Note the type in the event name matches the type of the first parameter, and is also the script where the
 * custom event is defined.