だから私はちょっとしたものを作ろうとしていて、乱数を生成する方法を探していたるところを見てきました。ただし、コードをどこでテストしても、結果は乱数ではありません。ここに私が書いた例があります。
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を与えます、私が欠けているものはありますか?