Nodes
Get Variable#
The Get Variable node allows you to retrieve the value of a variable that was previously set in your spell. This is useful when you need to access and use a variable's value at a later point in your spell's execution.
Inputs#
This node does not have any input sockets.
Outputs#
The Get Variable node dynamically generates output sockets based on the socketOutputs
configuration. Each output socket represents a variable value that will be retrieved.
Configuration#
hiddenProperties
(array, default:["hiddenProperties", "variableId", "socketOutputs", "label"]
): Specifies properties that should be hidden in the node's UI.variableId
(string, default:""
): The unique identifier of the variable to retrieve. This is typically set automatically when you create a new variable using the Set Variable node.variableNames
(array, default:[]
): An array of variable names that you want to retrieve values for. Each name in this array will generate a corresponding output socket.socketOutputs
(array, default:[]
): Specifies the output sockets for the node. Each item in the array represents an output socket and should have aname
property matching a variable name fromvariableNames
.
Example Usage#
Suppose you have a spell that fetches data from an API and stores the response in a variable using the Set Variable node. Later in the spell, you want to access that API response to extract specific data from it. Here's how you can use the Get Variable node to achieve this:
- Add a Set Variable node to your spell and configure it to store the API response in a variable named
apiResponse
. - Add a Get Variable node to your spell at the point where you need to access the
apiResponse
variable. - In the Get Variable node's configuration, set the
variableNames
property to["apiResponse"]
. This will generate an output socket for theapiResponse
variable. - Connect the output socket of the Get Variable node to the input of the node where you want to use the
apiResponse
value.
Now, when the spell executes, the Get Variable node will retrieve the value of the apiResponse
variable, making it available to downstream nodes through its output socket.
Best Practices#
- Make sure the
variableNames
array in the Get Variable node's configuration matches the names of the variables you want to retrieve. - If you have multiple variables to retrieve, you can add them to the
variableNames
array to generate corresponding output sockets. - Ensure that the variables you're trying to retrieve have been previously set using a Set Variable node in your spell.
Common Issues#
- If the Get Variable node is not retrieving the expected value, double-check that the variable name in the
variableNames
array matches the name used in the Set Variable node. - Make sure the Get Variable node is placed after the Set Variable node in your spell's execution flow. The variable must be set before it can be retrieved.
- If you've modified the variable's value between the Set Variable and Get Variable nodes, keep in mind that the Get Variable node will retrieve the most recent value of the variable.
By using the Get Variable node, you can easily access and use variable values throughout your spell, enabling more dynamic and flexible spell logic.