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 a name property matching a variable name from variableNames.

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:

  1. Add a Set Variable node to your spell and configure it to store the API response in a variable named apiResponse.
  2. Add a Get Variable node to your spell at the point where you need to access the apiResponse variable.
  3. In the Get Variable node's configuration, set the variableNames property to ["apiResponse"]. This will generate an output socket for the apiResponse variable.
  4. 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.