ComfyUI Node

Script

The conductor for this pack's execute-anything system

By Trung0246·Created 3 years ago·Updated about a year ago· 137
Script
  • _script_in
  • _script_out
_exec_mode
_sort_modeINT

Script is the orchestrator of the 0246 pack's "execute anything" family. On its own it does nothing - it's the node that collects and runs the instructions emitted by ScriptNode, ScriptRule, and ScriptPile. Those nodes produce SCRIPT_DATA packets describing "what node to run," "which pipe to feed it from," and "how to walk the inputs." Script is where the execution actually happens. It's the conductor; the others are the sheet music.

You'd reach for it when you want a chunk of your workflow - a sampler, a loader, a whole node - to run on demand, conditionally, or swept across a batch, in a way that vanilla ComfyUI's "run when inputs are ready" can't express. Build the scripted stack, wire the packets into a Script, set it to act, and it executes the whole composition in the order you defined.

How it works

The two inputs that matter are _exec_mode and _sort_mode.

  • _exec_mode - pass or act. pass just forwards the script data without running anything (handy for debugging or for building a script up incrementally). act is the real deal: it sorts the collected wrap packets, runs each pin-unpacker, invokes the exec function (or the rule that drives it), then runs the re-pack wrappers and hands the results back. Multiple nodes in one script are executed in the order given by their script_*_order widgets.
  • _sort_mode - controls that ordering, default "INT". It's passed straight to natsort, so you can write things like INT, LOCALE for locale-aware sorting, or other natsort flags (FLOAT, LOWERCASEFIRST, ...) separated by spaces. If you have several scripted nodes with numeric order fields, INT is what you want; when names get involved, start reading the natsort docs.

The optional _script_in takes a SCRIPT_PIPE so scripts can chain - one Script's output feeds the next's input. The node's outputs are _script_out (the SCRIPT_PIPE) plus one output per value the scripted node returned.

How to install it

The usual:

cd ComfyUI/custom_nodes
git clone https://github.com/Trung0246/ComfyUI-0246

restart, or ComfyUI Manager → search "ComfyUI-0246". No models. (Note natsort is a real dependency here - it's in requirements.txt and it does the ordering; if it's missing, sorting fails.)

Common issues & troubleshooting

Nothing executes. _exec_mode is on pass. Flip it to act. pass is a legitimate mode, it just doesn't run anything.

Nodes run in the wrong order. Your script_*_order values collide or _sort_mode isn't matching them. Order is natsort'd; "10" sorts before "9" under INT but not under default string sorting - set _sort_mode to match your order fields' semantics.

A scripted node's results are empty. The script has no SCRIPT_DATA to run - you forgot to wire a ScriptNode (or ScriptRule/ScriptPile) into this Script, or that node's output isn't connected. This is also where the pack's reputation catches up with you: the whole script system depends on internals and has been dormant since early 2025, so if ComfyUI's execution model shifted, the conductor may be the first thing to go quiet. Validate against your ComfyUI version before building around it.

Category0246

Inputs (3)

NameTypeDefaultDescription
_exec_modeCOMBO2 options: pass, act
_sort_modeSTRINGINT
_script_inoptSCRIPT_PIPE

Outputs (1)

NameTypeDescription
_script_outSCRIPT_PIPE