所以我正在尝试创建一些东西,我已经看到了寻找生成一个随机数的方法.然而,无论我在哪里测试我的代码,都会产生一个非随机数.这是我写的一个例子.
- 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)
无论我在哪里测试我的代码,我得到相同的结果.例如,当我在这里测试代码http://www.lua.org/cgi-bin/demo时,它总是以“Ion Thruster Machine Gun Blaster”结束,并且不随机化.对于这件事测试简单
- random = math.random (10)
- print(random)
给我9,有没有我失踪的东西?