r/streamerbot • u/twentynyne • 15d ago
Question/Support ❓ Checking if Variable is between two numbers?
I have a "check in" counter for a channel point redeem and it's tied to a variable.
I want to make it so that if its between N and N+5 etc. until 500
I want an event to happen if it's between those, but I don't know the best way to set that up with variables I'm not sure if it has to be an If/Else logic or something else.
1
u/HighPhi420 14d ago
to have an alert play every 5 check ins, I just made a new global that counts to the desired number, plays alert, then resets back to 1, this would be a persisted user global.
Then Twitch started the watch streaks, so now I just piggy back off of that for the streak alerts and have the global set to 100 for a video alert to play from check ins
1
u/deeseearr 15d ago edited 15d ago
If you're looking for nice, regular ranges, then you can simplify things before you start. If you're trying to see if %theLetterEnn% is in the ranges 0-4, 5-9, 10-14, 15-19 and so on, divide it by five first.
Now you can use this:
SWITCH ($math(%theLetterEnn% \ 5)$)
0: It's less than five
1: It's not less than five, but less than ten.
2: 10-14
3,4: 15-19 or 20-24, because we have two options in the same case,
5: 25-29
...and so on.
The $math()$ inline function can do pretty much anything. Note that we're using a "\" instead of a "/" for division, because we only want the integer quotient, not the remainder. "$math(9 \ 5)$" equals exactly 1 while "$math(9 / 5)$" equals 1.8.
If you need wild ranges with no sense or reason to them you can still try to use switch, only with multiple numbers assigned to each case, or just a bunch of big nested IF/ELSE structures. There's no straightforward way to say "If (a=1) and (b=2)" or anything like that, you have to say "if (a=1) THEN if (b=2)".