local x = math.random(1,500)
if x == 1 then
print("You Got a g")
end
if x == 2-10 then
print("You Got a f")
end
if x == "11,100" then
print("You Got a d")
end
if x == "101,200" then
print("You Got a c")
end
if x == 201-300 then
print("You Got a b")
end
if x == 301-500 then
print("You Got a")
end
print(x)所以在这个脚本中,我不知道当我把(if x == (what to put here) then)放在
我还在学剧本,所以没那么好
发布于 2022-01-15 10:34:06
除了Reinisdm答案之外,您还可以简化条件,因为第一个表达式总是真的。
local x = math.random(1,500)
if x == 1 then
print("You Got a g")
elseif x <= 10 then
print("You Got a f")
elseif x <= 100 then
print("You Got a d")
elseif x <= 200 then
print("You Got a c")
elseif x <= 300 then
print("You Got a b")
elseif x <= 500 then
print("You Got a")
end
print(x)发布于 2022-01-14 20:16:35
要检查多个数字,请使用<、<=、>、>=和and。
local x = math.random(1,500)
if x == 1 then
print("You Got a g")
elseif 2 <= x and x <= 10 then
print("You Got a f")
elseif 11 <= x and x <= 100 then
print("You Got a d")
elseif 101 <= x and x <= 200 then
print("You Got a c")
elseif 201 <= x and x <= 300 then
print("You Got a b")
elseif 301 <= x and x <= 500 then
print("You Got a")
end
print(x)https://stackoverflow.com/questions/70715866
复制相似问题