所以我正在尝试创建一些东西,我已经遍布整个地方寻找生成随机数的方法.但无论我在哪里测试我的代码,它都会产生一个非随机数.这是我写的一个例子.
local lowdrops = {"Wooden Sword","Wooden Bow","Ion Thruster Machine Gun Blaster"}
local meddrops = {}
local highdrops = {}
function randomLoot(lootCategory)
if lootCategory == low then
print(lowdrops[math.random(3)])
end
if lootCategory == medium then
end
if lootCategory == high then
end
end
randomLoot(low)
Run Code Online (Sandbox Code Playgroud)
无论我在哪里测试我的代码,我都会得到相同的结果.例如,当我在这里测试代码http://www.lua.org/cgi-bin/demo时,它总是以"Ion Thruster Machine Gun Blaster"结束,并且不要随机化.就此而言,测试简单
random = math.random (10)
print(random)
Run Code Online (Sandbox Code Playgroud)
给了我9,有什么我想念的吗?