Custom Node: Difference between revisions
Jump to navigation
Jump to search
m (→Settings: Adds another default value example) |
m (→Settings) |
||
Line 18: | Line 18: | ||
*'''Input Labels''': A comma-separated list of the input ports to this node. | *'''Input Labels''': A comma-separated list of the input ports to this node. | ||
*'''Output Labels''': A comma-separated list of the output ports to this node. | *'''Output Labels''': A comma-separated list of the output ports to this node. | ||
*'''Startup Script''': This script is triggered as soon as the node is created, and '''must''' emit this node's '''default value''' (for example, something like the [[Number Node]] would simply emit it's numeric value here, and a [[Slider Node]] would emit it's starting value here). | *'''Startup Script''': This script is triggered as soon as the node is created, and '''must''' emit this node's '''default value''' (for example, something like the [[Number Node]] would simply emit it's numeric value here, and a [[Slider Node]] would emit it's starting value here). Nodes with no Output ports do not need to emit anything. | ||
*'''Trigger Script''': The trigger script is run whenever the node recieves a new signal via an input port. It has access to a special "idx" variable that indicates the index of the input port (in order of their labels) that the incoming signal came from. | *'''Trigger Script''': The trigger script is run whenever the node recieves a new signal via an input port. It has access to a special "idx" variable that indicates the index of the input port (in order of their labels) that the incoming signal came from. | ||
Revision as of 13:42, 10 March 2023
Inputs
|
Outputs
|
Version Introduced 2.1 |
The Custom Node is a powerful node that allows you to directly write the JavaScript that runs within it to perform more complex operations on signal data.
Custom Nodes were introduced in firmware version 2.1 along with all basic nodes.
Settings
The settings found on the Custom Node allow you to configure the Node's input and output ports as well as the code that executes both on node start-up and also when the node recieves data.
- Script Name: Configures the name of this script, cosmetic only - only impacts the title of this node.
- Input Labels: A comma-separated list of the input ports to this node.
- Output Labels: A comma-separated list of the output ports to this node.
- Startup Script: This script is triggered as soon as the node is created, and must emit this node's default value (for example, something like the Number Node would simply emit it's numeric value here, and a Slider Node would emit it's starting value here). Nodes with no Output ports do not need to emit anything.
- Trigger Script: The trigger script is run whenever the node recieves a new signal via an input port. It has access to a special "idx" variable that indicates the index of the input port (in order of their labels) that the incoming signal came from.
Programming Tips and API
By default both the Startup and Trigger scripts are running within the context of the Node object itself, meaning they have access to it via the this keyword. Using this they can access some core functions:
- this.sendDataOnChannel( output_port_index : int, value : float ): This function emits a signal of value on output_port_index (which relates to the Output Labels respective indices). Connected nodes will recieve this value via the connected input port.
- this.inputs: this.inputs is an array of floats that relates to the respective indices of the input ports (as defined in the Input Labels). Note: Currently, this list can have null elements or not be the complete length of the inputs.
- idx: Only available in the Trigger Script, this value is the index of the Input Port that triggered this call to the "Trigger Script".