为什么在使用 if 语句时使用两个变量会给我一条错误消息?
Why does using two variables give me an error message when using an if statement?
我正尝试在 LUA 中为 Minecraft mod ComputerCraft 编写脚本。它应该派一只乌龟下来,挖一个洞,并在返回地面之前放置梯子。当乌龟没有足够的梯子时,我试图显示一个错误,但我收到一个阻止它 运行 的错误。 “mineDown :18: 尝试将字符串与预期数字进行比较,得到字符串。”
-- This gets the user to tell the turtle how far to dig down
print('How far down should I go?')
distDown = io.read()
distMoved = 0
ladders = turtle.getItemCount(13)
-- Check if the number of ladders is less than the distance needed to move. If so, returns error.
turtle.select(13)
if ladders < distDown then
error('Not enough ladders!')
end
我正尝试在 LUA 中为 Minecraft mod ComputerCraft 编写脚本。它应该派一只乌龟下来,挖一个洞,并在返回地面之前放置梯子。当乌龟没有足够的梯子时,我试图显示一个错误,但我收到一个阻止它 运行 的错误。 “mineDown :18: 尝试将字符串与预期数字进行比较,得到字符串。”
-- This gets the user to tell the turtle how far to dig down
print('How far down should I go?')
distDown = io.read()
distMoved = 0
ladders = turtle.getItemCount(13)
-- Check if the number of ladders is less than the distance needed to move. If so, returns error.
turtle.select(13)
if ladders < distDown then
error('Not enough ladders!')
end