Closed enauman closed 2 years ago
Ah, figured it out. The args passed to the macro are of type String so I had to convert it to int for the result to be returned correctly. This now works as expected:
> object randrange javascript
let min = int(args[0]);
return Math.floor(Math.random() * (100 - min) + min);
< object
I have a JavaScript macro to return a random integer between min and 100:
It often returns a number below the min. This script works fine in a plain html page, but won't work in a predictable way in this context.
I'm calling it like this:
The purpose is for the bot to guess the user's number. When prompted to guess higher it gets a random number between its last guess and 100.