Skip to content

Function Nodes

Define and call reusable functions inside node graphs. A core/functions/Function module defines the body, Define Function / Get Function / Call Function wire it up, and Call For Each maps a function over a list. Error Handler and Unpack Exception deal with failures raised inside a call. See Functions for the full concept walkthrough.

11 nodes.

Node Registry path
Error Handler core/ErrorHandler
Argument core/functions/Argument
Breakpoint core/functions/Breakpoint
Call For Each core/functions/CallForEach
Call Function core/functions/CallFunction
Define Function core/functions/DefineFunction
Get Function core/functions/GetFunction
Return core/functions/Return
Scoped API Function core/functions/ScopedAPIFunction
Unpack Exception core/functions/UnpackException
Run Module core/RunModule

Error Handler

core/ErrorHandler

A node that will catch unhandled errors in the graph and allow for custom error handling

This is an isolated node. When an unhandled error occurs, the supplied function is called with a single exc argument holding an exception wrapper (see UnpackException). If the function returns a truthy value the error is considered handled.

Inputs

Input Type Description
fn function The function to call when an error occurs

Argument

core/functions/Argument

Represents an argument to a function.

During function execution the value passed for this argument is cast to the declared type and emitted from the value output.

Outputs

Output Type Description
value any The value of the argument (during function execution)

Properties

Property Type Default Description
name str unset The name of the argument
typ str "str" The type of the argument. Choices: str, int, float, bool, list, any.

Breakpoint

core/functions/Breakpoint

Pauses graph execution at this point and notifies the node editor, allowing the current state to be inspected. Execution resumes when the breakpoint is released from the editor.

Breakpoints only trigger in the creative (node editor) environment - during normal gameplay the node simply passes the state through.

Inputs

Input Type Description
state any The state to pass through

Outputs

Output Type Description
state any The state input, passed through

Properties

Property Type Default Description
active bool True Whether the breakpoint is active

Call For Each

core/functions/CallForEach

Calls the supplied function on each item in the input list

The item is passed to the function as an argument

Inputs

Input Type Description
state any The state of the graph
fn function The function to call
items list,dict The list of items to iterate over

Outputs

Output Type Description
state any The state of the graph
results list The results of the function calls

Properties

Property Type Default Description
copy_items bool False Whether to copy the items list
argument_name str "item" The name of the argument to pass to the function

Call Function

core/functions/CallFunction

Takes a function wrapper input and a dict property to define arguments to pass to the function then calls the function

Inputs

Input Type Description
fn function The function to call
args any (optional) The arguments to pass to the function

Outputs

Output Type Description
result any The result of the function call

Properties

Property Type Default Description
args dict {} The arguments to pass to the function

Define Function

core/functions/DefineFunction

Defines a function from the connected nodes, which can be retrieved elsewhere in the graph via the GetFunction node.

This is an isolated node that never runs during normal graph execution. The node connected to nodes becomes the endpoint of the function - when the function is called, the nodes leading into the endpoint are executed.

Inputs

Input Type Description
nodes any The nodes to convert into a function
name str The name of the function

Properties

Property Type Default Description
name str unset The name of the function

Get Function

core/functions/GetFunction

Retrieves a function from the graph

This has no inputs and will return the function wrapper for the function defined by the DefineFunction node.

Outputs

Output Type Description
fn function The function wrapper
name str The name of the function

Properties

Property Type Default Description
name str unset The name of the function

Return

core/functions/Return

Represents the return value of a function.

When this node runs with a resolved input value, it sets the function's return value and stops execution of the function graph. If the input value is unresolved, execution continues normally.

Inputs

Input Type Description
value any The value to return

Outputs

Output Type Description
value any The value to return

Scoped API Function

core/functions/ScopedAPIFunction

Executes python code inside the quarantined scoped environment.

The code has access to the arguments dict, a result dict to populate, and the TM scoped API object.

Inputs

Input Type Description
state any The graph state
agent agent The agent whose client the scoped context runs against
arguments dict (optional) Arguments made available to the executed code

Outputs

Output Type Description
state any The state input, passed through
result any The result dict populated by the executed code

Properties

Property Type Default Description
code text unset The code to execute

Unpack Exception

core/functions/UnpackException

Unpacks an exception wrapper (as received by an ErrorHandler function) into its name and message.

Inputs

Input Type Description
exc exception The exception wrapper to unpack

Outputs

Output Type Description
name any The exception class name
message any The exception message

Run Module

core/RunModule

Provides a way to run a node module from memory

The module runs in an isolated state; running a module from within itself raises an error.

Inputs

Input Type Description
module any The module (Graph instance) to run

Outputs

Output Type Description
done bool True if module was executed successfully
failed str Error message if module execution failed
cancelled bool True if module execution was cancelled