Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Does the random class in Lua have a method for generating decimal numbers?

Asked by 5 years ago

I know that the Random class has

NextInteger()

but in every other language I've learned there has been a method to generate a number in a range of

0 - 1

for example maybe it will generate 0.4 or 0.2

Is there a method or function to do this in lua

Any help is appreciated thank you :)

0
The reason I'm posting this on here is the only thing I can find online pertains to the math.Random and that has been depreciated to my knowledge. 4d61736f6e 59 — 5y
0
math.random(1, 100) * 0.01 JohnerDev 27 — 5y
0
or math.random(1,10) * 0.1 for 0.1-1 JohnerDev 27 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

yes

0
Is there a way to do it without math.Random? 4d61736f6e 59 — 5y
0
Math.random is not deprecated. Whoever said that is trying to feed you false information. User#19524 175 — 5y
0
Alright thank you for your help :) 4d61736f6e 59 — 5y
Ad
Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
5 years ago

The :NextNumber(lo, hi) method of the Random class produces a number in the half-open range [lo, hi), defaulting to the range [0, 1).

Answer this question