Values and integration states (Twitch, Photoshop etc) within Touch Portal are global in nature. This means that within Touch Portal there is only one state. This is different for local states and Values. They are bound only to the Touch Portal event instance (On Press, On Event, global Event) they are part of. This comes especially in handy with Events and the states that belong to those events. But it can also greatly reduce the amount of Values you need to create for Value manipulation as you can use the local Values within a flow of actions.
Take for example a Twitch Chat Message state. Everytime your receive a new chat message in Twitch, Touch Portal registers this and stores it in a global state. As soon as a new message is received it will store that new message into that global state, overwriting the old state. The upside of this is that you are able to use this state everywhere within Touch Portal to make creative and complex flows and setups to do wonderful stuff for your viewers.
The downside is that you cannot rely on that value when you are using flows that take more time than the time between receiving the first and the second message. This especially becomes clear when you use Global Events with a queue.
This is where local states and Values come into play. These are connected to the flows they are part of. To put it more clearly with the Twitch example, each Event that is triggered when receiving a chat message will have its own set of states that will not change if a new chat message will be received. That will just create a new event flow with the new local states attached.
Here is a small overview image of how the Global states and Local states are related with Chat Messages coming in from Twitch:
As you can see with the global states you cannot rely on them to have the expected value during the full execution time of your flows. Each line originating from an event in the image represents the time of executing the flow of actions that the event triggers. While the first flow was still running, a new message was received. The global state is changed from that moment. Using that in the flow of the first event (which was still running) would have had an unwanted effect. With the local states however, you can see that they will stay the same expected value as long as the flow of actions is running.
To show how to use the local states we will show you an example of what we described above but now with an actual flow.
We assume you are aware of how a global Event is set up (if not, check out our guide on the subject first) but we will go through the flow step by step.
As you can see you use the same actions you use for global states and Values but you select the local variants when you want to use them locally.
The previous section already showed a bit about the local Values. With Touch Portal you will have 10 local values to your disposal that you can use locally within a flow of actions. They are bound to that single instance of a running flow.
You can use local Values for requirements that are only needed during the run of a flow, be it triggered by an event, a button press or anything else.