Add trigger input to GetVariable for execution ordering

- GetVariable now has optional 'trigger' input
- Connect SetVariable output to GetVariable trigger to ensure Set runs first
- Returns None instead of error when variable not found (graceful handling)
- Shows "NOT SET" in preview when variable missing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
jessesep
2025-12-05 01:50:39 +01:00
co-authored by Claude
parent 700ac580cc
commit afba842a33
+12 -3
View File
@@ -53,12 +53,19 @@ class SetVariable:
class GetVariable:
"""Retrieve data by variable name - shows preview on node"""
"""Retrieve data by variable name - shows preview on node
IMPORTANT: Connect the 'trigger' input to the SetVariable output to ensure
the variable is set before this node runs.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"variable_name": ("STRING", {"default": "my_var"}),
},
"optional": {
"trigger": ("*",), # Connect to SetVariable output to ensure execution order
}
}
RETURN_TYPES = ("*",)
@@ -67,10 +74,12 @@ class GetVariable:
CATEGORY = "variables"
OUTPUT_NODE = True
def get_var(self, variable_name):
def get_var(self, variable_name, trigger=None):
# trigger input is just for execution ordering, not used
if variable_name not in _variable_storage:
available = list(_variable_storage.keys())
raise ValueError(f"Variable '{variable_name}' not found. Available: {available}")
preview = f"{variable_name} = NOT SET (available: {available})"
return {"ui": {"text": [preview]}, "result": (None,)}
value = _variable_storage[variable_name]
preview = get_preview_text(variable_name, value)