Start timer based on the values of the buttons in an array
-
Hello everyone!
I have an array with several buttons. If ALL buttons have the value 0, the timer should be stopped.
If at least one of the buttons has a value greater than 0, the timer should be started.
Simple task but I can't figure it out right now. Does anyone have any ideas?
PS. I could of course implement it in a large if-query, but that would be very awkward...
Many thanks
Oli -
@Oli-Ullmann value change broadcaster that has a listener which loops through all these buttons.
If you have the references in an array,use that. If not, you can get it using a filter with Content.getComponents().
The code is simply
For (i in buttonArray)
If (i.getValue()! = 0)
ReturnStopTimer
So if they're all 0, return won't be called and it'll stop the timer. If any of them isn't, the function won't get to stopTimer
Sry for formatting, phone.
-
@aaronventure What about
if (myArr.contains(1))
? No need for a loop then. -
@aaronventure
Good idea, thank you very much! :-) I'll try that.@d-healey
Did you see that I was talking about the value of the buttons? I don't know how to apply your suggestion to buttons... -
@Oli-Ullmann Ah sorry I misread that. I thought you were storing the button values in an array.
-
@d-healey
Ah ok. :-) -
@d-healey
But another question:If I use
getAllComponents
, is there a way to select all components except the components with a specific name?In my case, I want to select all components except the components that have “UI” in their name. Do you know if this is possible?
-
@Oli-Ullmann It uses regex so it might be possible - ChatGPT could possibly help but might require some tweaks to its output because HISE regex is none standard
-
@d-healey
Ok, thank you! :-) -
@d-healey
Thank you, that worked.
For the “UI” example, the code is as follows:Content.getAllComponents(“^(?!.*UI).*$”);
-
@Oli-Ullmann Good to know, I might include that in a video.
Should also work with getAllModulators, getAllEffects, etc.
-
@d-healey
Yes, that's a great topic for a video! If I had known this earlier, it would have saved me a lot of time and programming effort. -
This post is deleted!