Scripts are written in JavaScript
There are two ways to write scripts. There is the script node and then there are variable property scripts.
A Script node automatically wires connections to get the values referenced by the script, then returns values through an automatically created outlet of the returned type.

The Script node can be triggered to Run manually or set to Live mode, where it runs when one of its connected input wires updates.
Main Script
async function main() {
console.log("Hello, World!")
return 123
}
This script is composed of an async main function. The script first prints (logs to the console) "Hello, World!", then returns a number. Keep the async function main() entry point with no parameters.
Variable Property Scripts


There is a script button on all variable properties. When in script mode, code can be written to calculate values.
Array Properties
In Flow Nodes 27.5.0, distinguish three uses of arrays:
An ordinary Value Array stores a list. Read it with
await property.values()and replace it withawait property.setValues(values).A Variable Array evaluates its list in its current shared mode. Read it with
await property.values(). Replace its list withawait property.setValues(values)only while it is in constant mode; spatial, connection, and script modes reject the write without switching modes or changing wiring.A Script node can return an array through its outlet, as in the Loops example below. Returning an array does not replace another node's property.
For example, name an Int List State node Numbers, then use a Script node to replace its Values property:
async function main() {
const values = node("Numbers").property("Values")
await values.setValues([1, 2, 3])
return await values.values()
}
setValues replaces the complete list, preserving order. Use [] to clear a supported array property. Await the setter before reading the changed property. Its completion includes ordinary source-model persistence and publication of value/count signals, but does not wait for every downstream evaluation to finish.
The same setter works for a Variable Array in constant mode. If it is spatial, connected, or scripted, the Promise rejects with an error; choose constant mode explicitly before trying to replace its list. Even [] does not bypass this restriction.
The returned array is a snapshot. Editing it with push, map, or index assignment does not edit the property; write the complete result back explicitly:
async function main() {
const values = node("Numbers").property("Values")
const snapshot = await values.values()
snapshot.push(4)
await values.setValues(snapshot)
return await values.values()
}
Each normal execution of this second example appends another value. Avoid calling it from a Live script whose input depends on the same Values property: a write can trigger the script again.
All incoming elements must match the property's type. For example, a Point array accepts [new Point(1, 2), new Point(3, 4)]; an Int array accepts only safe whole JavaScript numbers, not fractions, Boolean values, or numeric strings. An invalid element rejects the Promise without replacing any of the list. Catch errors with normal JavaScript try/catch. See the array-property reference for supported types and validation rules.
See Variable Properties for the distinction between ordinary and evaluated arrays.
Auto Wire Connections


With the use of the wire("Node", "Outlet") function, connections are automatically made. The first argument is the node name and the second argument is the outlet name.

(await wire("State 1", "Value")).x * 2.0
To get component values, like x or y from a Point, first await the wire value.
Script Node


async function main() {
console.log("Hello, World!")
return wire("State 1", "Value")
}
Wires are automatically connected with the wire() function.
Values

async function main() {
console.log("Hello, World!")
return new Point(1.0, 1.0)
}
Points and other types can be created and returned.
Loops

async function main() {
var points = []
for (let x = 0; x < 5; x++) {
for (let y = 0; y < 5; y++) {
let point = new Point(x, y)
points.push(point)
}
}
return points
}
Nested loops can be used to collect values to return. Here a bunch of Point types are created in a loop.
See the Script Reference for the node API and value types.