Механизъм ‐ Решения - gerryjekova/wheel-of-fortune-return GitHub Wiki
Hello lovely people of Streamer.bot forum. I am in a certain unfortunate situation that had me go crazy for a whole day and a half, but unfortunately I didn't find the solution, so here I am.
I will provide all relevant info below, but am open to requests for anything more if needed.
❔ **What I am trying to do?: **
~ I am trying to automate an operation for a logic connected to a concept in my stream.
~ The concept in question triggers with subs and bits (every 5 subs or every 1500 bits)
~ So when each of those events reaches the amount needed, an automatic concept event triggers.
... *So far, so good. * So something happens when the amount is reached, nice!
~ The thing is. What I would really like it to be doing is to automatically do the whole operation and add the +1 to the concept, since it is also tracked and it's a form of a variable that plays a role as a metric for tracking.
So I experienced the problem with trying to do 2x of the math operations to the global variables in every way I tried so far - even tried to get it done with C# to no avail... (I think it can probably be done with C#, but me and ChatGPT nor any of my friends figured it out)
i need C# code or inline math or even logic.. that:
- gets temp global 'wh' & temp global 'sp' both with default values of 0.
- 'a'| i need to set an argument 'a' = 'sp' divided by 5 (but I need this as the whole integer *Ex: sp = 31 .... I need it to return the result of (30/5), and for it to figure out it needs to be 30, as is the closest that can be divided to 5 to 31.... although if it ends up being 34 - i still need it to divide 30 by 5 instead of 35. )
- 'b'| i need to set an argument 'b' = 'sp' divided by 5 ( i need the remaining value of the operation for arguement 'a' only here - in this example, it would be 1 )
- 'c'| i need to then set an argument 'c' = wh + a
i need to then set temp global 'wh' to value of arguement 'c' then set temporary global 'sp' to value of 'b'
operations for 'a' & 'b' are what I can't find how to solve...
There are no operators that I can find that can perform these tasks with the current formulas and syntax of inline math. I read the documentation for Streamerbot, I read the documentation for mathparser for the operators
https://mathparser.org/mxparser-math-collection/operators/
This \ operator supposedly should return either the remainder or the rounded value... one of the two... but I need both. (And also tested it and it returned NaN) And yeah.
So, in this case if I want to use inline math I imagine it looking like:
- Get temp global "sp" to "sp", with default value of '0"
- Get temp global "wh" to "wh", with default value of '0"
- Set argument %a% to '$math( I need it to take %sp% and divide by 5...it has to round it up to the value that can divide by 5 here and give me the result )$' |||| this is the 1st operation i think i might need in C# code somehow
- Set argument %b% to '$math( has to calculate what the value of %sp% - %a% is )$' |||| this is the 2nd operation i think i might need in C# code somehow
- Set argument %c% to '$math( %wh% + %a% )$'
- Set temp global "wh" to the value of %c%
- Set temp global "sp" to the value of %b%
I did not explain how I tried fixing it with manual loops in the Streamer.bot UI and it ended up crashing the whole app, because I think there should be a way to do something like this in simple steps and the logic I tried to implement and the loops I caused are in the process and in big frustration were an absolutely bad idea and from what I know it uses system resources, so it could be why I crashed it.
Some of my confusion was rather, in the first part you wanted to round it down ( 34 to 30) to a dividable of 5, then in your second explanation you wanted to round it up (31 to 35)
At any reason it is definitely doable in just inline like this:
a being: $math( (%sp% - ( %sp% # %div% ) ) / %div% )$
to "round down" to the nearest dividable of the div
for "round up" : $math( %sp% + (%div% - ( %sp% % %div% ) ) % %div% )$
b: $math( %sp% - %a% )$
c: $math( %wh% + %a% )$
using System;
public class CPHInline
{
public bool Execute()
{
// (1) Get Temp Global "wh"
int wh = CPH.GetGlobalVar<int>("wh", false);
// (2) Get Temp Global "sp"
int sp = CPH.GetGlobalVar<int>("sp", false);
// divider (5 in your case)
int divider = 5;
// (3) "a" = "sp" / "divider"
int a = sp / divider;
// (4) "b" = "sp" % "divider" (whats left from dividing "sp" by "divider")
int b = sp % divider;
// (5) "c" = "wh" + "a"
int c = wh + a;
// Set Argument
CPH.SetArgument("c", c);
// Set Temp Global "wh" to "c"
CPH.SetGlobalVar("wh", c, false);
// Set Temp Global "sp" to "b"
CPH.SetGlobalVar("sp", b, false);
return true;
}
}