Class: wcPlay

wcPlay


new wcPlay( [options])

The main scripting engine.

Parameters:
Name Type Argument Description
options wcPlay~Options <optional>
Custom options.
Source:

Members


<static> var INSTANCE_LIBRARY

A global list of play engine instances that exist.

Source:

<static> var NODE

The different types of nodes.

Type:
  • string
Properties:
Name Type Default Description
ENTRY string 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.
PROCESS string process Process nodes perform a process, often very simple, and make up the bulk of a flow chain within the script.
STORAGE string storage Storage nodes are designed with a single purpose of storing data for use within the script.
COMPOSITE string 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.
Source:

<static> var NODE_LIBRARY

A global list of nodes that exist. All node types must add themselves into this list when they are coded.

Source:

<static> var PROPERTY

Determines how a property's control should be rendered within the editor view.

Type:
  • string
Properties:
Name Type Default Description
DYNAMIC string dynamic Displays the property as a string, but does not enforce or convert its type. String options are used.
TOGGLE string toggle Displays the property as a checkbox. Default options are used.
NUMBER string number Displays the property as a number control. Number options are used.
STRING string string Displays the property as a text field. String options are used.
SELECT string select Displays the property as a combo box control. Select options are used.
CUSTOM string custom Displays the property as a custom control. Custom options are used.
Source:

Methods


<static> function registerNodeType(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
name string The name of the node constructor.
displayName string The display name.
category string The display category name.
nodeType wcPlay.NODE The node's type.
Source:
Returns:
- Success or failure.
Type
boolean

<static> function unregisterNodeType(name) -> boolean

A global function that unregisters a node type from the library.

Parameters:
Name Type Description
name string The name of the node constructor.
Source:
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
node wcNode The node invoking this tracker.
parent wcPlay~FlowTracker <optional>
Parent tracker object.
callback function <optional>
Optional callback handler to call when this tracked chain has finished.
Source:
Returns:
- A chain tracker object.
Type
wcPlay~FlowTracker

function clear()

Clears all nodes from the script.

Source:

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
name string The name of the property.
type wcPlay.PROPERTY The type of property.
initialValue Object <optional>
A default value for this property.
options Object <optional>
Additional options for this property, see wcPlay.PROPERTY.
Source:
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
data Object | 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.
Source:
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
debug boolean <optional>
If supplied, will assign the debugging state of the script.
Source:
Returns:
- The current debugging state of the script.
Type
boolean

function destroy()

Destroys this instance.

Source:

function endFlowTracker(tracker)

Finishes a chain tracker.

Parameters:
Name Type Description
tracker wcPlay~FlowTracker The tracker to finish.
Source:

function error(args)

Outputs an error message.

Parameters:
Name Type Argument Description
args string <repeatable>
The log messages.
Source:

function import(serialData, name) -> boolean

Imports a script as a new composite node that can be retrieved with wcPlay#importedComposites.

Parameters:
Name Type Description
serialData string The serialized data to import.
name string The name of the composite node to create.
Source:
Returns:
- Whether the new composite node was created.
Type
boolean

function importedComposites() -> Array.<wcNodeCompositeScript>

Retrieves the list of all imported composite nodes.

Source:
See:
  • wcPlay#importComposite
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
name string The name of the property.
value Object <optional>
If supplied, will assign a new value to the property.
Source:
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
name string The class name to test.
Source:
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
name string The class name to test.
Source:
Returns:
- True if this named class is this class.
Type
boolean

function isRunning() -> boolean

Retrieves whether the script engine is running.

Source:
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.

Source:
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
serialData string The serialized data to load.
Source:
Returns:
- Success or failure.
Type
boolean

function log(args)

Outputs a log message.

Parameters:
Name Type Argument Description
args string <repeatable>
The log messages.
Source:

function nodeById(id) -> wcNode | null

Retrieves a node from a given ID, if it exists in this script.

Parameters:
Name Type Description
id number The ID of the node.
Source:
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.

Source:
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
className string The className of the nodes to retrieve.
Source:
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
search string The search value.
Source:
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
func string The renderer function to call.
args Array.<Object> A list of arguments to forward into the function call.
Source:

function notifyNodes(func, args [, includeEditorPalette])

Sends a custom notification event to all nodes.

Parameters:
Name Type Argument Description
func string The node function to call.
args Array.<Object> A list of arguments to forward into the function call.
includeEditorPalette boolean <optional>
If true, will also notify all nodes generated for use with editor palette views.
Source:

function paused( [paused]) -> boolean

Gets, or Sets the pause state of the script.

Parameters:
Name Type Argument Description
paused boolean <optional>
If supplied, will assign the paused state of the script.
Source:
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
name string The name of the property.
value Object <optional>
If supplied, will assign a new value to the property.
Source:
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
node wcNode The node being queued.
name string The entry link name.
fromNode wcNode The node causing the queue.
fromName string The exit link name.
forceQueue boolean <optional>
If true, will force the event into the queue rather than the waiting list.
tracker wcPlay~FlowTracker <optional>
Optional flow tracker.
Source:

function queueNodeProperty(node, name, value [, upstream])

Queues a node property value change to trigger on the next update.

Parameters:
Name Type Argument Description
node wcNode The node being queued.
name string The property name.
value Object The property value.
upstream boolean <optional>
If true, we are propagating the property change in reverse.
Source:

function removeProperty(name) -> boolean

Removes a global property.

Parameters:
Name Type Description
name string The name of the property to remove.
Source:
Returns:
- Fails if the property does not exist.
Type
boolean

function renameProperty(name, newName) -> boolean

Renames an existing global property.

Parameters:
Name Type Description
name string The current name of the global property to rename.
newName string The new desired name of the global property.
Source:
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.

Source:

function save() -> string

Serializes the script into a string that can be saved into a file and restored.

Source:
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
silent boolean If supplied, assigns a new silent state of the script.
Source:
Returns:
- The current silent state of the script.
Type
boolean

function start()

Initializes the script and begins the update process.

Source:

function stepping( [stepping]) -> boolean

Gets, or Sets the stepping state of the script.

Parameters:
Name Type Argument Description
stepping boolean <optional>
If supplied, will assign the stepping state of the script.
Source:
Returns:
- The current stepping state of the script.
Type
boolean

function stop()

Stops the script.

Source:

function triggerEvent(type [, options])

Triggers an event into the Play script.

Parameters:
Name Type Argument Description
type string The type name of the node (as displayed in the title).
options wcPlay~TriggerEventOptions <optional>
Optional parameters.
Source:

function update()

Update handler.

Source:

Type Definitions


typedef var Coordinates

A 2D positional coordinate.

Type:
  • Object
Properties:
Name Type Description
x Number The horizontal coordinate.
y Number The vertical coordinate.
Source:

typedef var FlowTracker

A chain tracker object. This behaves a lot like a linked-tree.

Type:
  • Object
Properties:
Name Type Argument Description
node wcNode The node.
parent wcPlay~FlowTracker The parent tracker.
callback function <optional>
Optional callback handler to call when this tracked flow is finished.
children Array.<wcPlay~FlowTracker> List of children that have spawned from this flow.
Source:

typedef var Options

Custom options available when constructing a new wcPlay instance.

Type:
  • Object
Properties:
Name Type Argument Default Description
silent Boolean <optional>
false If true, will disable debug logging on all nodes.
updateRate Number <optional>
25 The time, in milliseconds, between node updates.
updateLimit Number <optional>
100 The maximum number of nodes allowed to be updated in a single update. This minimizes the potential for script lock.
flowTrackerLimit Number <optional>
1000 The maximum flow trackers allowed (tracks when flow chains have fully executed).
debugging Boolean <optional>
true If true, debug break toggles on individual nodes will trigger the script to pause. Turn this off during production.
Source:

typedef var TriggerEventOptions

Options for the trigger event.

Properties:
Name Type Argument Description
name String <optional>
The event name to trigger (as displayed in the title between the parenthesis).
data Object <optional>
Optional data to be passed into the activation method of all entry nodes triggered.
done function <optional>
An optional callback handler to call when chains have executed completely.
Source: