ExecuteScript(string, object)

Cause a script to execute.

void ExecuteScript(
    string sScript,
    object oTarget
);

Parameters

sScript

oTarget


Description

Cause oTarget to run sScript as if called from an event and then return execution to the calling script.

The advantage of executing the script as if it were called by an event is, default variables like OBJECT_SELF are valid and initialized to oTarget. Additionally, references to possession and inventory are defaulted to oTarget. This makes scripts needed by say, OnUsed events on placeable items, easier to write and manage.

If sScript does not specify a valid compiled script in your module, nothing happens.



Remarks

sScript must be the name of a script in your module's list of scripts.


Version

1.22

Example

// Example 1 - Cause oTarget to execute the script named "sc_example" as if it were called by one of oTarget's events.
ExecuteScript("sc_example", oTarget);

See Also

categories: Miscellaneous Functions


 author: Brett Lathrope, editor: Jochem van 't Hull
 Send comments on this topic.