Custom Nodes
The built-in library covers a lot of ground, but eventually you’ll want a node that does exactly your thing. The xript node editor lets you define custom nodes directly inside epixtudio. Name, ports, a JavaScript script, no external files.
This tutorial builds a ROT13 cipher node from scratch.
What You’ll Build
A rot13 node that takes a text input and outputs the ROT13-encoded version. ROT13 shifts each letter 13 places in the alphabet, so hello becomes uryyb. Apply it twice and you get the original back. Useless in production, perfect for learning.
Step 1: Open the Node Editor
In the Library panel on the left, scroll to the bottom and click + Create Node. The xript node editor opens as a two-column dialog:
- Left — name, category, description, and port definitions
- Right — a JavaScript code editor for the processing logic
Step 2: Fill in the Basics
- Name:
rot13 - Category:
custom(or whatever you want; this determines where it appears in the Library) - Description:
Shifts each letter 13 places in the alphabet
Step 3: Define the Ports
Input ports are what your node receives. Click + Add Input and fill in:
- Name:
text - Type:
Text
Output ports are what your node produces. There’s already a default result output with type Any. Change it:
- Name:
result - Type:
Text
One text input, one text output. That’s the whole interface.
Step 4: Write the Script
In the code editor on the right, replace the default script with:
const text = inputs.text();
const result = text.replace(/[a-zA-Z]/g, (c) => {
const base = c <= 'Z' ? 65 : 97;
return String.fromCharCode(((c.charCodeAt(0) - base + 13) % 26) + base);
});
result;
Three things to know about xript scripts:
- Access inputs via
inputs.portName(). The function call matters;inputs.portNamewithout the parens won’t work. - The last expression is the output. Whatever the final line evaluates to becomes the node’s result.
- Multiple outputs require returning a JSON object with keys matching port names:
({ result: "foo", other: "bar" })
Step 5: Create It
Click Create. Your node now appears in the Library under the category you chose.
Step 6: Use It
- Drag
rot13from the Library onto the canvas (or find it with Tab quick search) - Add a text/text node and type
hello worldin the Inspector - Connect the text node’s output to
rot13’stextinput - Press F5 to evaluate
The rot13 node outputs uryyb jbeyq.
Chain a second rot13 after the first. The output is hello world again. That’s the whole point of ROT13.
Editing and Deleting
Hover over your custom node in the Library and click Edit Node in the tooltip. The editor reopens with your settings populated. Change anything, hit Save, and existing instances on the canvas pick up the updated script on next evaluation.
To delete, open the editor and click the red Delete button at the bottom left.
Script Tips
Error handling — if your script throws, the node shows an error in its preview and the log panel. No try/catch needed; the sandbox catches it.
Working with JSON — inputs arrive as their declared type. A Json port gives you a parsed object:
const data = inputs.data();
const names = data.map(item => item.name);
names;
Number crunching — a Number port gives you an actual number, not a string:
const a = inputs.a();
const b = inputs.b();
Math.sqrt(a * a + b * b);
Multiple outputs — return an object with keys matching your output port names:
const text = inputs.text();
({
upper: text.toUpperCase(),
lower: text.toLowerCase(),
length: text.length
});
Persistence
Custom nodes are saved to your local database. They survive restarts, appear in the Library, and work in any graph. They’re yours.
What’s Next
- Node Reference — see how built-in nodes work for inspiration
- xript Guide — the full xript manifest system for advanced extensions