Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Use of diagrams #953

Open
themegaxandy opened this issue Dec 19, 2023 · 4 comments
Open

[Feature Request] Use of diagrams #953

themegaxandy opened this issue Dec 19, 2023 · 4 comments

Comments

@themegaxandy
Copy link

Is your feature request related to a problem? Please describe.
The Advanced Scene Switcher plugin could... be even more advanced. Using diagrams can make macros more complex, it can cause loops to be made (or avoided), new conditions to be made even after actions, and race condition problems could be avoided this way. More details below.

A little context: I really like these automation tools, I even use them a lot on Android. Many people use MacroDroid, but I don't think it is that advanced, as it is based on the concept of IFTTT (IF This, Then That).

However, I use another application called Automate, which uses diagrams to make its automations. What is the advantage of this model? Well, we don't have the limitation of IFTTT. We can put an If, then an action, and even after that, an If again, freely and without restrictions.

Describe the solution you'd like
The Advanced Scene Switcher could make use of diagrams to build even more advanced macros.

An example use case would be like this:
I have a keyboard shortcut to change the "window capture" source for the window that is currently in the foreground. But I don't want it to make a sudden change. So before I change the source's properties, I make a smooth transition for it to leave the scene (with another plugin), then change the properties, and then another smooth transition to enter back to the scene.
However, switching capture windows may take a while depending on the window/game (my computer is slow). So, with this suggestion, I could put an If in the middle of these actions, so that it would wait for some video to be captured with the already existing If "if not video source has no output"! (Possibly with a timeout too, the plugin can't wait forever.)

Another example use case would be like this:
I have a TTS generation app. The plugin's job is to run the command with the "Run" action to make the app generate the TTS wav file, and then play it in OBS through the "media source" source. However, the plugin cannot play the wav before the app finishes generating it. That's where this suggestion would be useful. The plugin would proceed in the same way as described in the previous example.

Describe alternatives you've considered
Making such a change to the plugin can be difficult, I know. I've already tried to do this with the help of several helper macros, but I had a lot of problems with race conditions.
I need the macros to run in order, as I have several macros with variables, and splitting the macros with helper macros ends up overwriting those variables prematurely when the macro's conditions are met repeatedly and very quickly.

The plugin already runs the macros in order (as long as the "run macros in parallel to other macros" check box is unchecked), however, this order ends up being broken in this helper macros scheme.
Using diagrams could cause these helper macros to be merged into one. And it can even help with organizing macros. (My macro list is already big enough, even with the help of folders.)
The only way currently to run macros in an orderly way, avoiding race conditions, is through the "Macro" action of "run actions". However, this form performs actions regardless of the conditions of the macro in question.

A possible less expensive solution is: In the "Macro" action of the plugin, where we define it to run actions from a specific macro, there could be a check box to wait for the conditions of the selected macro. Because currently, this action only runs the macro actions regardless of their conditions.

How can this function be implemented without breaking existing macros? Currently the json of macros are made with an array of conditions, another of actions, and another of else.
This suggestion could be implemented with another array, separate from the existing ones, which would be called diagram. And there it would import all existing condition blocks and action blocks.

Additional context
Here's a screenshot of the app I mentioned, to give you an idea of what a diagram template would look like. It is done through "blocks", which can be made up of conditions, or made up of actions.

@WarmUpTill
Copy link
Owner

Thank you very much for the suggestion and extensive write-up!

I do agree that this would be a neat way to extend the functionality of the plugin, but I have to be honest and say that I likely won't have the time to implement something like this any time soon.

Feel free to contact me directly if you need support / ideas on how your current macro setup might be improved to avoid race conditions.

A possible less expensive solution is: In the "Macro" action of the plugin, where we define it to run actions from a specific macro, there could be a check box to wait for the conditions of the selected macro. Because currently, this action only runs the macro actions regardless of their conditions.

Adding the checkbox to the UI would be easy, but I think the functionality would be quite tricky to implement.
Since macros are executed sequentially this could very easily lead to deadlocks, which of course would be undesirable.
But I will keep it in mind and try to think of something.

@themegaxandy
Copy link
Author

Thanks for reading my feedback and keeping it in mind! Your explanation was clear and understandable. So I'll close the issue for now, and don't worry I'll find a way to optimize my macros. If I need any additional help, I'll post it on the OBS forum.

@WarmUpTill
Copy link
Owner

I will leave the issue open just in case I find myself having a lot of free time on my hand and want to work on this :)

And it will make it easier for others to find this issue in case they want to request something similar.

@WarmUpTill WarmUpTill reopened this Dec 20, 2023
@Destroy666x
Copy link
Contributor

Tasker is much more advanced and the prime example to be used for automation apps IMO (except that Automate is more user-friendly). E.g. with concept of states which are kind of like if/else here but more advanced and refined. Generally with more possibilities in terms of flow.

A possible less expensive solution is: In the "Macro" action of the plugin, where we define it to run actions from a specific macro, there could be a check box to wait for the conditions of the selected macro

This could be just replaced by "Run macro" action instead, which would do the whole flow of macro (condition -> if/else action), which would be more user-friendly. Or perhaps a different concept of "functions" runnable only from macro actions could be introduced, but that's even more work ofc.

Another workaround for your use case of TTS would be something like "wait until" action also available in Tasker. E.g. wait until a variable is set to value and then a macro that checks if a text file changes and sets a var to its contents. Then the command could modify the text file once earlier process finishes. But probably not easy to implement either with how this plugin works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants