companion
companion copied to clipboard
Trigger on variable changed
Is this a feature relevant to companion itself, and not a module?
- [X] I believe this to be a feature for companion, not a module
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the feature
There is an existing trigger for when a variable becomes equal to a value.
There is a missing case, where you want to trigger on a variable change, regardless of the value.
New trigger, Variable Change, which just takes the name of a variable, or an expression made of lots of variables
Usecases
Game scoring. Hold the score in a variable with buttons that increment/decrement it
Whenever the score changes, use an action via the Variable Changed trigger to send the new score to the display system (e.g. OBS) as a text update.
WIthout this feature you need to add the text update action everywhere that might change the score.
I think that this needs some thought on how best to implement. I would prefer for it to be done as part of the 'feedbacks' triggers system, as I think it will be useful to be able to stack conditions (eg, you dont want it to run when you are playing out a clip), but I dont know how that will work. Perhaps it needs to be a 'pulse'?
This might be appropriate to move to https://github.com/bitfocus/companion-module-bitfocus-companion, depending on the concluded plan
Maybe all triggers should have a list of ALL and NONE conditions. Only if all the ALLs and none of the NONEs are true does the trigger happen.
Should the trigger happen later?
Should triggers be on events of on state changes?
That is a good point, the feedbacks are essentially state based and fire when entering the target state. (I think there is a request somewhere to also do things when leaving the target state). But the other types of triggers are essentially events that fire..
Perhaps we need to go back and rethink the triggers some more, to make the other types be events, with the feedbacks being used to 'filter' out events. Then this variable_changed would be one of those events, as well as an 'state_changed' event to handle the feedbacks changing
A 'trigger' is an event. A trigger pull.
I think there are three types of event:
- A true event: button press, button release, change of state, startup etc
- A state entry
- A state exit
Each trigger can have a Condition which is
This allows you to build any logic you need
A trigger in the UI could have multiple triggers with the same condition list
Example
I want to set up device 1 with respect to device 2
Trigger on:
- Device 1 enters online state
- Device 2 enters online state
- Device 2 feedback x changes
Conditions:
- AND -- Device1 state = online -- Device2 state = online
Action: Device1 set my_state = device2 variable
+1 for this trigger on variable changed 👍
Use case: I have created an internal: Run shell path
action that has a Target Variable (stdout)
set. The command that is run outputs JSON which I would like to parse when the action completes and extract useful values from the JSON to assign to other variables that can be used to drive feedback.
Any updates on this? I have a use case:
I need to send OSC message to a software with a number corresponding to a variable. There are a number of ways this variable can be changed, so it won't do any good having the trigger check a specific button or other variable to send the message. It's currently doable by creating a trigger for each possible variable value, but as you can imagine this stacks up fast. Additionally, there seems to be no way to reorder triggers either, so it turns into a giant pile of mess very fast (maybe I should create a request for that too). If there was a function to trigger when variable changes, then I could have a single trigger that would send an OSC message with the variable being a part of the address/path every time the variable changes
This will be possible in v3.0. Its still a little way off (v2.4 is coming first) See #2165 for info on the complete change
This is in the 3.0 betas