Let’s continue with the next data type which is the Logical. It’s designated by the red color. It’s a simple two-state value, can be OFF or ON. When it appears as an output pin it usually designates the existence or non-existence of a state of a module. For e.g. on the Timer module it shows that the timer is running or not. Currently it’s ON, but if I stop the timer then it’s OFF.
The editor of the logical value is a simple On/Off switch that can be toggled by clicking. If the focus is on the name of the property then - similarly to the scalar editor - we can use the left and right arrow keys to turn OFF and ON the value. The space key toggles between the two states.
The logical values can be used for various conditional controlling. A simple example is the If module that switches between two values depending on the logical value. Let’s wire the Running pin of the Timer into it. The two values are already set. So in the case of ON the module will output 35, otherwise 14. In other words if the Timer is running we get 35, otherwise 14.
There are several logical operator modules to enable connecting multiple conditions. As a simple example let’s suppose we have two Timers, and we want to emit the 35 value only if both timers are running. To do that we simply wire the two timers into an And module and wire on the result into the If module. We can see that if only one of the timers is running we still get 14, but if both are running we get 35.
Our next data type is the Trigger. It’s designated by the purple color. It servers the purpose of sending an impulse-like signal. When it appears as an output pin it usually designates the reaching of a specific state or the ending of a process within a module. For e.g. we have a Timer module which runs in Looping mode in one second cycles. It has an Elapsed output that signals the reaching of the end time. In its peeker we can see a one second periodic signal.
Input pins of the trigger type usually enables starting or stopping some process within a module. For e.g. let’s use the Elapsed signal of the Timer to periodically restart the Video Player. We can see that the video jumps back to the start in each second.
The trigger does not appear as an editable value in the Pin Values editor. But it has a button, so we can manually trigger something by clicking the button. For e.g. we can start playing the video. Of course these pins can be exposed, thus we can get Play/Stop buttons on the Dashboard.
Trigger data type has a very close relationship with the Logical type. A trigger signal can be seen as a Logical value that has the ON value for a single frame only then falls back to OFF. The two types are convertible into each other. We can wire a logical value into a trigger pin. Let’s wire it into the Restart pin, and expose the video out to be able to see the result. The following happens: when the logical value changes from OFF state into ON state the trigger input pin interprets it as a trigger signal. The opposite transition doesn’t do anything of course. We can see that on each turning ON the video restarts. This behaviour can be very useful. For e.g. we my want to start a process in the system simultaneously with the turning on an effect.
Let’s see an example when we want to trigger something both on turning ON and turning OFF a logical value. By adding a Not module which inverts the logical value we can produce a trigger signal when the value is being turned OFF. Let’s connect the two signal using a Trigger Any module which send a signal whenever it receives signal on any of its inputs. We can see that the video restarts on both turning ON and OFF the switch.
Both logical and trigger values are convertible into numeric values. If we wire a logical value into a numeric input pin, then the OFF value becomes 0 and the ON value becomes 1. It’s very simple. In the opposite direction the 0 value becomes OFF, and any other values - so not only the 1, but all non-zero values, for e.g. 0.32 - becomes ON.
Similarly a numeric value can be used as a trigger. Let’s connect it to Restart. In this case, as we expect, when the numeric value changes from zero to any non-zero value, it is interpreted as a trigger signal.