Nodes
Flip Flop#
The Flip Flop node is a flow control node that alternates between two states - "on" and "off" - each time it receives a flow signal. It's useful for creating toggle switches, alternating between two actions, or tracking binary state in your spells.
Inputs#
flow(flow): The incoming flow signal that triggers the state change.
Outputs#
on(flow): Emits a flow signal when the node switches to the "on" state.off(flow): Emits a flow signal when the node switches to the "off" state.isOn(boolean): Outputs the current state of the node.truewhen in the "on" state,falsewhen in the "off" state.
Configuration#
This node has no configuration options.
Usage#
- Add a Flip Flop node to your spell.
- Connect a flow signal to the
flowinput. This could come from a button press, a trigger node, or any other node that emits a flow signal. - Connect the
onandoffoutputs to the nodes you want to trigger alternately with each incoming flow signal. - If needed, connect the
isOnoutput to a node that needs to know the current state, like a Boolean Filter or a Condition node.
Example#
Imagine you want to create a spell that toggles a light on and off with a button press. Here's how you could use the Flip Flop node:
- Add a Button Press node to detect the button press.
- Connect the Button Press node's
pressedoutput to the Flip Flop node'sflowinput. - Connect the Flip Flop node's
onoutput to a Turn On Light node. - Connect the Flip Flop node's
offoutput to a Turn Off Light node.
Now, each time the button is pressed, the Flip Flop node will alternate between its "on" and "off" states, turning the light on and off accordingly.
Best Practices#
- Use the Flip Flop node when you need to alternate between two actions or states with each incoming signal.
- The Flip Flop node remembers its state even if the spell is stopped and restarted. Keep this in mind if your spell needs to always start in a particular state.
Common Issues#
- Make sure the incoming flow signal is properly connected to the
flowinput. The Flip Flop node won't change state without an incoming signal. - Remember that the Flip Flop node starts in the "off" state by default when the spell is first run. If you need it to start in the "on" state, you can use a Set Variable node to set
isOntotrueat the start of your spell.