Difference between revisions of "RegisterForModEvent - Form"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Darkconsole
m (Undo revision 52358 - this is very not true. please present your case in the talk section and we'll work through it.)
imported>Pickysaurus
(→‎Notes: Clarified persistent nature of ModEvent registrations)
Line 34: Line 34:
== Notes ==
== Notes ==
*Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
*Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
*You must register for ModEvents after every game load!
*ModEvent registrations are persistent and are stored in the MCBR record of the SKSE co-save. If you mod relies on these registrations being persistent it is '''strongly''' recommended that you register for the event again after each game load, if the user deletes this file for any reason it could break your mod.<sup>[1]</sup>


== See Also ==
== See Also ==

Revision as of 14:34, 31 May 2020

SKSE Member of: ActiveMagicEffect Script, Alias Script, and Form Script

Registers a custom event callback for given event name. Registrations have to be refreshed after each game load.

Syntax

Function RegisterForModEvent(string eventName, string callbackName) native

;The event:
Event callbackName(string eventName, string strArg, float numArg, Form sender)
EndEvent

Parameters

  • callbackName: The name by which you can catch the event.

Examples

; Register to receive the ModEvent:
; named HectorHitMe with the callback of OnHectorHitMe
RegisterForModEvent("HectorHitMe", "OnHectorHitMe")

Event OnHectorHitMe(string eventName, string strArg, float numArg, Form sender)
;Do something
EndEvent

Notes

  • Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
  • ModEvent registrations are persistent and are stored in the MCBR record of the SKSE co-save. If you mod relies on these registrations being persistent it is strongly recommended that you register for the event again after each game load, if the user deletes this file for any reason it could break your mod.[1]

See Also