User Tools

Site Tools


building:scripts:events:script_based

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

building:scripts:events:script_based [2019/03/11 00:07]
Mavrixio created
building:scripts:events:script_based [2019/03/11 00:22] (current)
Mavrixio
Line 1: Line 1:
 ====== Script Based Events ====== ====== 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]] system.
  
 ===== Registering / Unregistering a Script Based Event ===== ===== Registering / Unregistering a Script Based Event =====
Line 12: Line 14:
 </​code>​ </​code>​
 ... 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. ... 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 [[https://​nwnlexicon.com/​index.php?​title=ExecuteScript|ExecuteScript]] 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:
 +<​code>​
 +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);
 +</​code>​
  
building/scripts/events/script_based.1552262830.txt.gz ยท Last modified: 2019/03/11 00:07 by Mavrixio

phpBB Appliance - Powered by TurnKey Linux