EOS help - random numbers
Posted: Wed Mar 10, 2021 10:10 am
So, I've been trying to wrap my head around the EOS editor, and... well, so far not going well. For me coding is like an extraterrestrial language translated into Chinese that I'm trying to read in English via Google Translate... I tried to look up how things work in google, but... the explanations tend to confuse me even more. Like, I figured out that if I want random numbers, I use mathrandom command. So, from another thread on this forum I got this code, with the addendum that I should just change the min / max numbers to suit my needs:
Since this code is supposed to get a random number from 1 to 20, I figured if I wanted a number between 50-200, I just change it to this:
Well, first test result gave me 244 as result, so I'm clearly misunderstanding how this works. Tried to google to see how this code actually works, but I got explanations like:
I also wanted to figure out how to do a complex score system, like the ones in my lottery teases, but I gave up on that real quick. If I can't even get a random number, I'm clearly too dumb for this...
Code: Select all
var myNumber = Math.floor((Math.random() * 20) + 1);
console.log('The number is %s', myNumber)Code: Select all
var myNumber = Math.floor((Math.random() * 200) + 50);
console.log('The number is %s', myNumber)Which... I don't understand anything of. I've never had a mind for math, so this whole thing just makes my head hurt. I just want to know how to do a basic random.org roll without having to link players to random-org...The Math.random() function returns a floating-point, pseudo-random number in the range 0 to less than 1 (inclusive of 0, but not 1) with approximately uniform distribution over that range — which you can then scale to your desired range. The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user.
I also wanted to figure out how to do a complex score system, like the ones in my lottery teases, but I gave up on that real quick. If I can't even get a random number, I'm clearly too dumb for this...



