Script Methods
From C4 Engine Wiki
There are several types of script methods that are defined in the engine module. An application module can define any number of its own custom script methods as well, and they will show up in the palette on the left side of the script editor window.
The following table describes the operation of the methods built into the engine that appear under the Basic and Standard tabs in the editor.
|
Method |
Description |
Duration |
|
Null |
Performs no operation. This method is useful for joining multiple fibers of execution at the end of a loop or as a starting node for the script when a loop begins at the first method that performs some action. |
Completes immediately. |
|
Evaluate Expression |
Evaluates a text expression and outputs the result. For a description of expression syntax, see Expression Evaluation in Scripts. (If the expression contains a syntax error, then the method is colored bright yellow in the Script Editor.) |
Completes immediately. |
|
Call Controller Function |
Calls a function of the controller attached to the method's target node. The specific settings depend on the purpose of the function itself. |
Completes when the function indicates that is has finished what it's doing. |
|
Change Settings |
Changes one or more settings for the object referenced by the target node. |
Completes immediately. |
|
Activate Controller |
Activates the controller attached to the method's target node. The effect depends on the controller being activated. In the case that the target node has a script controller attached to it, the script is executed. |
Completes immediately. |
|
Get External Variable |
Retrieves the value of a specific variable belonging to the script controller attached to the target node of the method. This method is useful for reading values from other scripts in the world and storing them in variables local to the running script. If the variable being retrieved has object scope, then its current value is returned, but if it has script scope, then its initial value is always returned. |
Completes immediately. |
|
Set External Variable |
Sets the value of a specific variable belonging to the script controller attached to the target node of the method. This method is useful for copying values from variables local to the running script to object-scope variables of other scripts in the world. Only variables having object scope can be modified using this method. |
Completes immediately. |
|
Get Script Time |
Outputs the amount of time that has elapsed, as a floating-point value measuring in seconds, since the script began running. The script time is updated once per frame. The time is guaranteed to be exactly 0.0 during the first frame in which the script is running. |
Completes immediately. |
|
Delay |
Waits for a specified amount of time. |
Completes after the specified time has elapsed. |
|
Random Integer |
Generates a random integer in a specified range and outputs the value. The boolean result is set to true if the value is not zero and false otherwise. |
Completes immediately. |
|
Random Float |
Generates a random floating-point number in a specified range and outputs the value. The boolean result is set to true if the value is not zero and false otherwise. Note that in this case, a false result is extremely unlikely because the return value would have to be exactly 0.0. |
Completes immediately. |
|
Get String Length |
Outputs the length of an input string. |
Completes immediately. |
|
Wake Controller |
Awakens a controller. |
Completes immediately. |
|
Sleep Controller |
Puts a controller to sleep. |
Completes immediately. |
|
Get Controller Wake State |
Returns a boolean value indicating whether a controller is currently awake. |
Completes immediately. |
|
Enable Node |
Enables its target node. |
Completes immediately. |
|
Disable Node |
Disables its target node. |
Completes immediately. |
|
Get Node Enable State |
Returns a boolean value indicating whether the target node is currently enabled. |
Completes immediately. |
|
Delete Node |
Deletes its target node. The node to which the script is attached, or any of its ancestors, cannot be deleted with this method. |
Completes immediately. |
|
Enable Interactivity |
Enables interactivity for its target node. |
Completes immediately. |
|
Disable Interactivity |
Disables interactivity for its target node. |
Completes immediately. |
|
Get Node Interactivity State |
Returns a boolean value indicating whether the target node is currently interactive. If the target node does not possess the Interactivity property, then the return value is false. |
Completes immediately. |
|
Show Geometry |
Shows the target node. Has no effect if the target is not a geometry node. |
Completes immediately. |
|
Hide Geometry |
Hides the target node. Has no effect if the target is not a geometry node. |
Completes immediately. |
|
Get Geometry Visibility State |
Returns a boolean value indicating whether the target node is visible. If the target node is not a geometry node, then the return value is false. |
Completes immediately. |
|
Get Object-Space Position |
Returns a 3D point containing the object-space position of the target node. |
Completes immediately. |
|
Get World-Space Position |
Returns a 3D point containing the world-space position of the target node. |
Completes immediately. |
|
Play Ambient Sound |
Plays a sound resource without 3D spatialization. |
Completes when the sound has finished playing. |
|
Play Sound Source |
Plays the target node. Has no effect if the target is not a source node. |
If the source was already playing or the source is looping, then the method completes immediately. Otherwise, the method completes when the source finishes playing. |
|
Stop Sound Source |
Stops its target node. Has no effect if the target is not a source node. |
Completes immediately. |
|
Set Material Color |
Changes the color of one of the material attributes assigned to its target node. Has no effect if the target is not a geometry node. Since materials are shared, all geometry nodes using the same material, not necessarily just the target, are affected. Thus, to change a material color for only one geometry node, it should use a unique material. This method can change any material attribute that includes a color, such as diffuse, specular, or emission. |
Completes immediately. |
