ScriptCall
ScriptCall (str classname, str funcname, args)
Usage
Executes a script-defined function. If the first argument of the function to execute is of type Actor, the activator of the script is passed and is stored in that argument. This allows the activator to be accessed by said function.
Parameters
- classname: the name of the actor class in which the function is defined.
- funcname: the name of the function to execute. Only static functions are executable.
- args: the arguments, if any, to pass to the specified function. The types of arguments the function could have are int, bool, double, string, name, color and sound. double is passed as a fixed-point value, color as an integer value, and name and sound as strings.
Return value
The value the executed function returns. The value's type is the same as the passed arguments' types, in addition to void.
Examples
This script gives the player a unique TID. This is achieved by executing FindUniqueTid, which is defined in Actor.
script "SetPlayerTID" ENTER { // Only if the player does not already have a TID. if(ActivatorTID() == 0) { int ptid = ScriptCall("Actor", "FindUniqueTid", 0, 0); Thing_ChangeTID(0, ptid); Log(s:"TID changed to ", d:ptid); // Print a message. } }
Note that ACS already has a function which can get a unique TID. The above example is for educational purposes.
If executed, this GivePresent function gives the activator of the script an item and logs a message. The item is specified by the present argument.
// In ZScript: class ExampleClass { static void GivePresent (Actor activator, string present) { // Only players get the item. if(activator && activator.player) { activator.A_GiveInventory(present); activator.A_Log("You received a wonderful present!", true); } } } // In ACS: script "GetGift" (void) { ScriptCall("ExampleClass", "GivePresent", "Soulsphere"); }