ItsABadger (talk | contribs) (Created page with "=== Script Based Events === Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn't matter, but if you want to do something only when something happen to a specific object, you should use the Variable Based Event system. === Registering / Unregistering a Script Based Event === This is d...") |
TorturedCats (talk | contribs) (Apply approved Sinfar resource-page layout: native headings, compact tables and responsive navigation; preserve existing content.) |
||
| Line 1: | Line 1: | ||
=== Script Based Events === | <div class="sf-page sf-article-page sf-guidance-family sf-resource-page"> | ||
<div class="sf-family-path">[[Main Page|Main Page]] · [[:Category:Builders Tools|Builder resources]]</div> | |||
<div class="sf-hero"><div class="sf-eyebrow">Builder resources · Scripting reference</div> | |||
<div class="sf-title">Registered Events</div> | |||
<p>Registration, parameters, and execution of script-based events.</p> | |||
</div> | |||
== On this page == | |||
<div class="sf-task-index">[[#Script_Based_Events|Script Based Events]] [[#Registering_/_Unregistering_a_Script_Based_Event|Registering / Unregistering a Script Based Event]] [[#Creating_/_Running_a_Script_Based_Event|Creating / Running a Script Based Event]]</div> | |||
== Script Based Events == | |||
<div class="sf-content-panel"> | |||
Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn't matter, but if you want to do something only when something happen to a specific object, you should use the [[Variable Based Events|Variable Based Event]] system. | Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn't matter, but if you want to do something only when something happen to a specific object, you should use the [[Variable Based Events|Variable Based Event]] system. | ||
</div> | |||
== Registering / Unregistering a Script Based Event == | |||
<div class="sf-content-panel"> | |||
This is done with the 2 following functions: | This is done with the 2 following functions: | ||
| Line 12: | Line 27: | ||
The parameters can be accessed the same way as the original script and the caller will be the same. | The parameters can be accessed the same way as the original script and the caller will be the same. | ||
</div> | |||
== Creating / Running a Script Based Event == | |||
= | <div class="sf-content-panel"> | ||
If in the middle of a script you want to notify everyone interested by what is happening, you can use the [[https://nwnlexicon.com/index.php?title=ExecuteScript%7CExecuteScript Execute Script]] function, but better, you can use the RunEvent(ReturnType) functions, which will create a script based event that can be registered, have parameters and a return value: | If in the middle of a script you want to notify everyone interested by what is happening, you can use the [[https://nwnlexicon.com/index.php?title=ExecuteScript%7CExecuteScript Execute Script]] function, but better, you can use the RunEvent(ReturnType) functions, which will create a script based event that can be registered, have parameters and a return value: | ||
| Line 26: | Line 44: | ||
* <code>vector RunEventVector(string sScript, object oTarget, array aParams);</code> | * <code>vector RunEventVector(string sScript, object oTarget, array aParams);</code> | ||
* <code>location RunEventLocation(string sScript, object oTarget, array aParams);</code> | * <code>location RunEventLocation(string sScript, object oTarget, array aParams);</code> | ||
</div> | |||
<div class="sf-footerlinks">[[Main Page|Return to Main Page]] · [[Player Guidance Directory]] · [[:Category:Builders Tools|Builder resources]]</div> | |||
</div> | |||
Latest revision as of 22:51, 10 November 2026
Registration, parameters, and execution of script-based events.
On this page
Script Based Events
Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn't matter, but if you want to do something only when something happen to a specific object, you should use the Variable Based Event system.
Registering / Unregistering a Script Based Event
This is done with the 2 following functions:
void RegisterEvent(string sEvent, string sScript);
void UnregisterEvent(string sEvent, string sScript);
For example, the following line:RegisterEvent("pc_ev_death", "myerf_ev_pcdeath")... will cause the myerf_ev_pcdeath script to be called before and every time that the pc_ev_death is about to be executed.
The parameters can be accessed the same way as the original script and the caller will be the same.
Creating / Running a Script Based Event
If in the middle of a script you want to notify everyone interested by what is happening, you can use the [Execute Script] function, but better, you can use the RunEvent(ReturnType) functions, which will create a script based event that can be registered, have parameters and a return value:
int RunEvent(string sScript, object oTarget, array aParams);int RunEventInt(string sScript, object oTarget, array aParams);object RunEventObject(string sScript, object oTarget, array aParams);string RunEventString(string sScript, object oTarget, array aParams);float RunEventFloat(string sScript, object oTarget, array aParams);effect RunEventEffect(string sScript, object oTarget, array aParams);array RunEventArray(string sScript, object oTarget, array aParams);dictionary RunEventDictionary(string sScript, object oTarget, array aParams);vector RunEventVector(string sScript, object oTarget, array aParams);location RunEventLocation(string sScript, object oTarget, array aParams);