Difference between revisions of "Event Handling"
imported>Odessa (created. source obse docs, loverlab tut, me) |
imported>Ana |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
Event handling is added by NVSE 4.6, and was ported from OBSE. | |||
Events include block types found in object scripts, such as "OnHit", "OnDeath", and so on, as well as other events involving loading, saving, and exiting the game. | Events include block types found in object scripts, such as "OnHit", "OnDeath", and so on, as well as other events involving loading, saving, and exiting the game. | ||
An event handler allows response to game events, without having to attach scripts directly to objects. Instead, the scripter uses [[SetEventHandler]] to register a [[User Defined Function]] as a handler for a specific event. When an event occurs during gameplay, NVSE will invoke any handlers that correspond to it, passing information about the event to their function through its arguments. | An event handler allows response to game events, without having to attach scripts directly to objects. Instead, the scripter uses [[SetEventHandler]] to register a [[User Defined Function]] as a handler for a specific event. When an event occurs during gameplay, NVSE will invoke any handlers that correspond to it, passing information about the event to their function through its arguments. | ||
Each event expects its handlers to accept a specific set of arguments. The in built events, including any required arguments (listed in the order in which they should appear in the function definition) are listed in the table below. In addition, [[User Defined | Each event expects its handlers to accept a specific set of arguments. The in built events, including any required arguments (listed in the order in which they should appear in the function definition) are listed in the table below. In addition, [[User Defined Event]]s are possible. | ||
{| class="wikitable" style="width:100%; text-align:left" align="center" | {| class="wikitable" style="width:100%; text-align:left" align="center" | ||
Line 16: | Line 18: | ||
|| [[OnActorUnequip]] || Unequipped || Unequipped | || [[OnActorUnequip]] || Unequipped || Unequipped | ||
|- | |- | ||
|| [[OnAdd]] || | || [[OnAdd]] || AddedItem || AddedTo | ||
|- | |- | ||
|| [[OnClose]] || Closed || Closer | || [[OnClose]] || Closed || Closer | ||
Line 44: | Line 46: | ||
|| [[OnPackageDone]] || Actor || Package | || [[OnPackageDone]] || Actor || Package | ||
|- | |- | ||
|| [[OnReset]] || WhatsReset | || [[OnReset]] || WhatsReset || WhatsReset (duplicate of first parameter) | ||
|- | |- | ||
|| [[OnSell]] || SoldInvItem || Seller (Player only?) | || [[OnSell]] || SoldInvItem || Seller (Player only?) | ||
Line 100: | Line 102: | ||
*[http://obse.silverlock.org/obse_command_doc.html#Events OBSE Documentation] | *[http://obse.silverlock.org/obse_command_doc.html#Events OBSE Documentation] | ||
*[http://www.loverslab.com/topic/39417-tutorial-nvse4-part-5-event-handlers-user-defined-events-udes/ A tutorial on NVSE Events] | *[http://www.loverslab.com/topic/39417-tutorial-nvse4-part-5-event-handlers-user-defined-events-udes/ A tutorial on NVSE Events] | ||
==Note on OnActorEquip== | |||
GetType 40 (=weapons) on rEquipped will return false, because rEquipped is the ammo loaded on the weapon itself. So, if there are no avaiable ammos, or it's a melee weapon, it won't even fire up. Also, on load, if the weapon is out it will fire the event, since it loads ammos. | |||
==Note on OnAdd== | |||
11/feb/2017 - OnAdd seems firing only in Gamemode when picking something from the ground, but not in MenuMode when moving stuff on containers. | |||
Latest revision as of 15:43, 11 February 2017
Event handling is added by NVSE 4.6, and was ported from OBSE.
Events include block types found in object scripts, such as "OnHit", "OnDeath", and so on, as well as other events involving loading, saving, and exiting the game.
An event handler allows response to game events, without having to attach scripts directly to objects. Instead, the scripter uses SetEventHandler to register a User Defined Function as a handler for a specific event. When an event occurs during gameplay, NVSE will invoke any handlers that correspond to it, passing information about the event to their function through its arguments.
Each event expects its handlers to accept a specific set of arguments. The in built events, including any required arguments (listed in the order in which they should appear in the function definition) are listed in the table below. In addition, User Defined Events are possible.
Event | First | Second | |
---|---|---|---|
OnActivate | Activator/Activated | ActionRef | |
OnActorEquip | Equipper | Equipped | |
OnActorUnequip | Unequipped | Unequipped | |
OnAdd | AddedItem | AddedTo | |
OnClose | Closed | Closer | |
OnCombatEnd | Target | Ender | |
OnDeath | Killed | Killer | |
OnDrop | Dropper | Dropped | |
OnHit | Target | Attacker | |
OnHitWith | Target | Weapon | |
OnLoad | Loaded | ||
OnMagicEffectHit | Target | BaseEffect | |
OnMurder | Murdered | Murderer | |
OnOpen | Opened | Opener | |
OnPackageStart | Actor | Package | |
OnPackageChange | Actor | Package | |
OnPackageDone | Actor | Package | |
OnReset | WhatsReset | WhatsReset (duplicate of first parameter) | |
OnSell | SoldInvItem | Seller (Player only?) | |
OnStartCombat | Target | Starter | |
OnTrigger | Trigger | ActionRef | |
OnTriggerEnter | Trigger | ActionRef | |
OnTriggerLeave | Trigger | ActionRef | |
SayToDone | Speaker | Info | |
- - - | |||
Corresponding to Plugin API | |||
ExitGame | |||
ExitToMainMenu | |||
LoadGame | |||
SaveGame | |||
QQQ | |||
PostLoadGame | |||
RuntimeScriptError | |||
DeleteGame | |||
RenameGame | |||
RenameNewGame | |||
NewGame | |||
DeleteGameName | |||
RenameGameName | |||
RenameNewGameName |
Event Functions[edit | edit source]
External Links[edit | edit source]
Note on OnActorEquip[edit | edit source]
GetType 40 (=weapons) on rEquipped will return false, because rEquipped is the ammo loaded on the weapon itself. So, if there are no avaiable ammos, or it's a melee weapon, it won't even fire up. Also, on load, if the weapon is out it will fire the event, since it loads ammos.
Note on OnAdd[edit | edit source]
11/feb/2017 - OnAdd seems firing only in Gamemode when picking something from the ground, but not in MenuMode when moving stuff on containers.
This article is a stub, you can help the community by expanding it.