!commands edit !d50 $(eval var guess = decodeURIComponent("$(querystring)"); var rand = Math.floor((Math.random() * 50) + 1); var difference = Math.Abs(guess - rand); if difference == 0 "You guessed it right!" else "You were off by " + difference ".")
HELP - Comparing input to a random number, generating output based on the difference
4 replies
Hey @Opal Mammoth!
You weren't too far off getting it right, it was just a question of syntax/formatting.
You'll notice that I included one more test to handle errors in case someone doesn't specify a number between 1 and 50.
!editcom !d50 $(eval g=decodeURIComponent(`$(querystring)`);if(isNaN(g)||g==``||g<1||g>50){`Please specify a number between 1 and 50, $(user).`}else{r=Math.floor(Math.random()*50)+1;d=Math.abs(g-r);d==0?`$(user) guessed it right!`:`$(user) was off by ${d}.`;})
Yes, it's definitely possible using the quote system API, not easy at all, but I've made similar commands for others in the past if I remember correctly, so I can give it a try, however you need to have a clear idea of the leveling system you want.