Mod:Creation Kit/Events Reference

Events are special functions that the game will call when something happens. Note that simply defining an event won't make the game call it, you must follow the name and argument list of an event that the game

New events may not be defined in non-native objects to avoid typos being recognized as new events.

Event Definition


Function headers must always be followed by a standard function block and "EndEvent", unless they are native (which are handled by the game).

Event Header


The event header is identical to the function header, but does not allow for return types or allow for the "Global" flag.

Remote Event Header


The sender parameter must be the same type as the type specified in the event name, and it is followed by the parameters that the event on the remote object sends. The identifier must be the name of an event defined on the object type, and it must not be defined in a parent object type. In other words, the object type must be the least-derived type that contains the event.

Custom Event Header


The sender parameter must be the same type as the type specified in the event name, and must be followed by an arguments parameter of type "Var[]". The identifier must be the name of the custom event defined in the object type.

Parameters
The parameters are identical to the function parameter list, but should match the data that the game will send to the event.

Examples
Event OnActivate(ObjectReference akActivator) PlayAnimation("CoolStuff") endEvent
 * A simple activate event handler

An example of a remote event handler: Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActivator) PlayAnimation("CoolStuff") endEvent

An example of a custom event handler: Event MyQuestScript.MyCustomEvent(MyQuestScript akSender, Var[] akArgs) Debug.Trace("Got MyCustomEvent from " + akSender + " with arguments " + akArgs) endEvent

Creating a Custom Event
'CustomEvent'

The "CustomEvent" keyword defines a new custom event that this script can send, kind of like a variable. Whenever someone defines a custom event receiver function, or passes a custom event name to a function, it is checked against this particular element. You cannot define a custom event with the same name as any other function or event in your script, or your parent script.

Examples
CustomEvent MyCustomEvent
 * Define a MyCustomEvent event

Special Variables
Event special variables are identical to a non-global function's.

Calling Events
Calling events is identical to calling a function.

Remote and custom events may not be directly called. Directly calling an event will not trigger remote events on other scripts.