new wcPlay( [options])
The main scripting engine.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
options |
wcPlay~Options |
<optional> |
Custom options. |
Members
-
<static> varINSTANCE_LIBRARY -
A global list of play engine instances that exist.
-
<static> varNODE -
The different types of nodes.
Type:
- string
- Source:
Properties:
Name Type Default Description ENTRYstring entry Entry nodes mark the beginning of an execution flow chain and are usually triggered by some type of event that happens outside of the script. PROCESSstring process Process nodes perform a process, often very simple, and make up the bulk of a flow chain within the script. STORAGEstring storage Storage nodes are designed with a single purpose of storing data for use within the script. COMPOSITEstring composite Composite nodes are a group of nodes combined into a single visible node. They appear in the composite section of the node palette for easy duplication within your script. -
<static> varNODE_LIBRARY -
A global list of nodes that exist. All node types must add themselves into this list when they are coded.
-
<static> varPROPERTY -
Determines how a property's control should be rendered within the editor view.
Type:
- string
- Source:
Properties:
Name Type Default Description DYNAMICstring dynamic Displays the property as a string, but does not enforce or convert its type. String options are used. TOGGLEstring toggle Displays the property as a checkbox. Default options are used. NUMBERstring number Displays the property as a number control. Number options are used. STRINGstring string Displays the property as a text field. String options are used. SELECTstring select Displays the property as a combo box control. Select options are used. CUSTOMstring custom Displays the property as a custom control. Custom options are used.
Methods
-
<static> functionregisterNodeType(name, displayName, category, nodeType) -> boolean -
A global function that registers a new node type into the library. This is called automatically when a new extended node type is defined, you should not have to do this manually.
Parameters:
Name Type Description namestring The name of the node constructor. displayNamestring The display name. categorystring The display category name. nodeTypewcPlay.NODE The node's type. Returns:
- Success or failure.- Type
- boolean
-
<static> functionunregisterNodeType(name) -> boolean -
A global function that unregisters a node type from the library.
Parameters:
Name Type Description namestring The name of the node constructor. Returns:
- True if the node type has been found and removed.- Type
- boolean
-
function beginFlowTracker(node [, parent] [, callback]) -> wcPlay~FlowTracker -
Creates a chain tracker for a callback method.
Parameters:
Name Type Argument Description nodewcNode The node invoking this tracker. parentwcPlay~FlowTracker <optional>
Parent tracker object. callbackfunction <optional>
Optional callback handler to call when this tracked chain has finished. Returns:
- A chain tracker object.- Type
- wcPlay~FlowTracker
-
function clear() -
Clears all nodes from the script.
-
function createProperty(name, type [, initialValue] [, options]) -> boolean -
Creates a new global property (can be used with the global storage node).
Parameters:
Name Type Argument Description namestring The name of the property. typewcPlay.PROPERTY The type of property. initialValueObject <optional>
A default value for this property. optionsObject <optional>
Additional options for this property, see wcPlay.PROPERTY. Returns:
- Fails if the property does not exist.- Type
- boolean
-
function customData( [data]) -> Object -
Gets, or Sets, a custom data object to the script that will be saved and restored with the output file data.
NOTE: Binding new data will always replace any data that may have been previously bound.Parameters:
Name Type Argument Description dataObject | function <optional>
If supplied, will assign a new custom data. If you supply a function, it will be invoked when retrieving the data. If not supplied, will retrieve the currently bound data. Returns:
- The current custom data object.- Type
- Object
-
function debugging( [debug]) -> boolean -
Gets, or Sets the debugging state of the script.
Parameters:
Name Type Argument Description debugboolean <optional>
If supplied, will assign the debugging state of the script. Returns:
- The current debugging state of the script.- Type
- boolean
-
function destroy() -
Destroys this instance.
-
function endFlowTracker(tracker) -
Finishes a chain tracker.
Parameters:
Name Type Description trackerwcPlay~FlowTracker The tracker to finish. -
function error(args) -
Outputs an error message.
Parameters:
Name Type Argument Description argsstring <repeatable>
The log messages. -
function import(serialData, name) -> boolean -
Imports a script as a new composite node that can be retrieved with wcPlay#importedComposites.
Parameters:
Name Type Description serialDatastring The serialized data to import. namestring The name of the composite node to create. Returns:
- Whether the new composite node was created.- Type
- boolean
-
function importedComposites() -> Array.<wcNodeCompositeScript> -
Retrieves the list of all imported composite nodes.
Returns:
- An array of imported composite nodes.- Type
- Array.<wcNodeCompositeScript>
-
function initialProperty(name [, value]) -> Object -
Gets, or Sets a global property initial value.
Parameters:
Name Type Argument Description namestring The name of the property. valueObject <optional>
If supplied, will assign a new value to the property. Returns:
- The current value of the property, or undefined if not found.- Type
- Object
-
function instanceOf(name) -> boolean -
Retrieves the class name of this object.
Parameters:
Name Type Description namestring The class name to test. Returns:
- True if the named class is an instanced of this class.- Type
- boolean
-
function isA(name) -> boolean -
Retrieves the class name of this object.
Parameters:
Name Type Description namestring The class name to test. Returns:
- True if this named class is this class.- Type
- boolean
-
function isRunning() -> boolean -
Retrieves whether the script engine is running.
Returns:
- Whether the script engine is running.- Type
- boolean
-
function listProperties() -> Array.<wcNode~PropertyData> -
Retrieves a list of all global properties and their values for this script.
Returns:
- A list of all property data.- Type
- Array.<wcNode~PropertyData>
-
function load(serialData) -> boolean -
Loads a script from previously serialized data generated by save.
Parameters:
Name Type Description serialDatastring The serialized data to load. Returns:
- Success or failure.- Type
- boolean
-
function log(args) -
Outputs a log message.
Parameters:
Name Type Argument Description argsstring <repeatable>
The log messages. -
function nodeById(id) -> wcNode | null -
Retrieves a node from a given ID, if it exists in this script.
Parameters:
Name Type Description idnumber The ID of the node. Returns:
- Either the found node, or null.- Type
- wcNode | null
-
function nodeLibrary() -> wcNodeLibrary -
Retrieves the node library for this script. This is an object that allows you to manage the nodes you are allowed to use in this script.
Returns:
- The node library list.- Type
- wcNodeLibrary
-
function nodesByClassName(className) -> Array.<wcNode> -
Retrieves a list of nodes that match a given class name, if they exists in this script.
Parameters:
Name Type Description classNamestring The className of the nodes to retrieve. Returns:
- A list of all found nodes.- Type
- Array.<wcNode>
-
function nodesBySearch(search) -> Array.<wcNode> -
Retrieves a list of nodes that match a given search filter.
Parameters:
Name Type Description searchstring The search value. Returns:
- A list of all found nodes.- Type
- Array.<wcNode>
-
function notifyEditors(func, args) -
Sends a custom notification event to all renderers.
Parameters:
Name Type Description funcstring The renderer function to call. argsArray.<Object> A list of arguments to forward into the function call. -
function notifyNodes(func, args [, includeEditorPalette]) -
Sends a custom notification event to all nodes.
Parameters:
Name Type Argument Description funcstring The node function to call. argsArray.<Object> A list of arguments to forward into the function call. includeEditorPaletteboolean <optional>
If true, will also notify all nodes generated for use with editor palette views. -
function paused( [paused]) -> boolean -
Gets, or Sets the pause state of the script.
Parameters:
Name Type Argument Description pausedboolean <optional>
If supplied, will assign the paused state of the script. Returns:
- The current pause state of the script.- Type
- boolean
-
function property(name [, value]) -> Object -
Gets, or Sets a global property value.
Parameters:
Name Type Argument Description namestring The name of the property. valueObject <optional>
If supplied, will assign a new value to the property. Returns:
- The current value of the property, or undefined if not found.- Type
- Object
-
function queueNodeEntry(node, name, fromNode, fromName [, forceQueue] [, tracker]) -
Queues a node entry link to trigger on the next update.
Parameters:
Name Type Argument Description nodewcNode The node being queued. namestring The entry link name. fromNodewcNode The node causing the queue. fromNamestring The exit link name. forceQueueboolean <optional>
If true, will force the event into the queue rather than the waiting list. trackerwcPlay~FlowTracker <optional>
Optional flow tracker. -
function queueNodeProperty(node, name, value [, upstream]) -
Queues a node property value change to trigger on the next update.
Parameters:
Name Type Argument Description nodewcNode The node being queued. namestring The property name. valueObject The property value. upstreamboolean <optional>
If true, we are propagating the property change in reverse. -
function removeProperty(name) -> boolean -
Removes a global property.
Parameters:
Name Type Description namestring The name of the property to remove. Returns:
- Fails if the property does not exist.- Type
- boolean
-
function renameProperty(name, newName) -> boolean -
Renames an existing global property.
Parameters:
Name Type Description namestring The current name of the global property to rename. newNamestring The new desired name of the global property. Returns:
- Fails if the property was not found or if the new name is already used.- Type
- boolean
-
function reset() -
Resets all volotile data in the script.
-
function save() -> string -
Serializes the script into a string that can be saved into a file and restored.
Returns:
- A serialized string with the entire script.- Type
- string
-
function silent(silent) -> boolean -
Gets, or Sets whether the script is running in silent mode.
Parameters:
Name Type Description silentboolean If supplied, assigns a new silent state of the script. Returns:
- The current silent state of the script.- Type
- boolean
-
function start() -
Initializes the script and begins the update process.
-
function stepping( [stepping]) -> boolean -
Gets, or Sets the stepping state of the script.
Parameters:
Name Type Argument Description steppingboolean <optional>
If supplied, will assign the stepping state of the script. Returns:
- The current stepping state of the script.- Type
- boolean
-
function stop() -
Stops the script.
-
function triggerEvent(type [, options]) -
Triggers an event into the Play script.
Parameters:
Name Type Argument Description typestring The type name of the node (as displayed in the title). optionswcPlay~TriggerEventOptions <optional>
Optional parameters. -
function update() -
Update handler.
Type Definitions
-
typedef var Coordinates -
A 2D positional coordinate.
Type:
- Object
- Source:
Properties:
Name Type Description xNumber The horizontal coordinate. yNumber The vertical coordinate. -
typedef var FlowTracker -
A chain tracker object. This behaves a lot like a linked-tree.
Type:
- Object
- Source:
Properties:
Name Type Argument Description nodewcNode The node. parentwcPlay~FlowTracker The parent tracker. callbackfunction <optional>
Optional callback handler to call when this tracked flow is finished. childrenArray.<wcPlay~FlowTracker> List of children that have spawned from this flow. -
typedef var Options -
Custom options available when constructing a new wcPlay instance.
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description silentBoolean <optional>
false If true, will disable debug logging on all nodes. updateRateNumber <optional>
25 The time, in milliseconds, between node updates. updateLimitNumber <optional>
100 The maximum number of nodes allowed to be updated in a single update. This minimizes the potential for script lock. flowTrackerLimitNumber <optional>
1000 The maximum flow trackers allowed (tracks when flow chains have fully executed). debuggingBoolean <optional>
true If true, debug break toggles on individual nodes will trigger the script to pause. Turn this off during production. -
typedef var TriggerEventOptions -
Options for the trigger event.
- Source:
Properties:
Name Type Argument Description nameString <optional>
The event name to trigger (as displayed in the title between the parenthesis). dataObject <optional>
Optional data to be passed into the activation method of all entry nodes triggered. donefunction <optional>
An optional callback handler to call when chains have executed completely.