Fologram for Grasshopper contains flow control tools for dynamically enabling and disabling components or whole groups in your grasshopper definition. These flow controls can be used to build applications with multiple states or modes that a user can efficiently switch between depending on the functionality required.
Using the State Gate
The State Gate is a component with variable output parameters that you can add, remove and rename to suit the expected input to the state gate. Any ouput parameter with a name matching the given input text will be enabled and all components connected to this output will expire and update. All other parameters (and connected components) are disabled. If the state gate receives an input with no matching outputs, all output parameters are disabled.
State Gate Inputs
In our example, we create two buttons and give them two arbitrary names, next and last. The Track Clicks component outputs the name of any detected clicked objects and this name is used as the input to our State Gate. We rename the outputs of the State Gate to match our button names, next and last.
Building the counter functionality as groups
We create a global variable to store the current value of our counter. This is given the arbitrary name of counter. The current value of the counter is reported to the user in the mixed reality experience using the Send Text Tags component.
We then create a group of components that when updated will increase the value of the counter by one. We do this by getting the value of the counter global variable, using the addition component to add 1 to this value, and then updating the value of counter. These components are grouped together, and the group is connected to the next output of the state gate.
The same process is repeated with a subtraction component to decrease the value of counter by one when the components are updated. This group is connected to the last output of the state gate.