# complicated math command

so i have this math api http://twitch.center/customapi/math?expr=\$(querystring) and im wondering if i can grab the data from it, check if its higher or lower than a given number and if it is higher than said number then it will have a 7030 chance of saying (70%) the solution or (30%) “math is hard”, but also if the number is lower than the given number then it will be a 5050 chance to say the solution or “math is hard”.

tbh im not at all sure if it is possible so this may just be a waste of time, but if it is possible and someone can tell me what it is, it would be greatly appreciated

atm the command line for just a 5050 split of solving the equation or saying “math is hard” and its this…

\$(eval Math.round(Math.random())?`\$(urlfetch http://twitch.center/customapi/math?expr=\$(querystring))`:`math is hard`)

yes i know its overly complicated and prolly not really worth it but it would be a nice novelty command, thanks if anyone can help me with this <3

@nerxxy Try this,

``````!addcom -cd=5 !math \$(eval x=\$(urlfetch http://twitch.center/customapi/math?expr=%24(querystring)); try { if ( x < Lower_Num ) { `50:50 chance to say ` + x } else if ( x > Greater_Num ) { `70:30 chance of saying ` + x } } catch(e) { `Math is hard` })
``````

Replace “`Lower_Num`” with your lower number and “`Greater_Num`” with your greater number.

Hmm, if you face any error, then let me know, I will fix it. Actually, I didn’t test this command yet.

Regards

@Ritik_Ranjan thanks for the help, but the command seems to not work, do i need to have the -cd=5? since im only a nightbot manager for the channel i cant add commands via chat, this is what i get when i do the command tho
again, many thanks if you can get this working for me even in my own channel i get the error

Hey @nerxxy!

Your explanation of what you want is really confuse, it took me more than 5 reads to understand, please be clearer in the future, otherwise we won’t help!

From what I understand, if the result is higher than a specific number you want a 30% chance the response to be “math is hard”, and if the result is lower than the same specific number you want a 50% chance the response to be “math is hard.”
Did I get that right? See how concise and easier to understand it is? That’s how it should have been. And in case English isn’t your native language, so it isn’t mine either.

Anyway, back to the command:

``````\$(eval r=Math.floor(Math.random()*10)+1; m=\$(urlfetch http://twitch.center/customapi/math?expr=\$(querystring)); if(m>SPECIFIC_NUMBER){r>7?`Math is hard.`:`\${m}`}else{r>5?`Math is hard.`:`\${m}`})
``````

Replace `SPECIFIC_NUMBER` by the number of your choice and you’re good to go.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.