【发布时间】:2019-11-25 22:53:01
【问题描述】:
我是 LUA 的新手,在使用函数 math.random(...) 时需要代码方面的帮助。问题是如果我需要生成我刚刚使用的整数值
math.random(-1, 1) -- This is gonna be -1, 0 or 1. Profit.
但如果我需要介于 -1 和 0 之间的非整数?
math.random(-1.0, 1.0) -- Still -1, 0 or 1. No profit.
我尝试使用这个:-1.01, 1.01,但它不会在我需要的值之间生成一个数字。
如何生成 1 到 0 之间的非整数值?
【问题讨论】:
-
我认为您的问题有误,math.random() 生成的随机值介于 0 和 1 之间。
-
@poorandunlucky 是的,我想我只是忘记了,但我的意思是我需要在 x 和 y 变量之间生成非整数值,而不仅仅是 1 和 0。
标签: random lua random-seed