本文介绍了关于输入的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在观看youtube视频以学习Lua,我不明白为什么他在以下代码中使用了tinput而不是输入:
Im watching a youtube video to learn Lua, what I dont understand is why he used tinput instead of input in the following code:
print("Welcome to the game")
input = ""
inv = {"coin", "sword", "armor"}
while imput ~= "exit" do
print("What do you want to do?")
input = io.read()
if input == "inspect" then
print("Youre in a cave. There is an exit.")
elseif input == "exit" then
print("You left the cave.")
elseif input == "inv" then
for i,v in pairs(inv) do
print(i,v)
end
else
print("You didnt write a valid command...")
end
end
input = ""
while input ~= "follow path" do
print("What do you want to do?")
input = io.read()
if input == "inspect" then
print("There is a cave behind you. Youre on a cliff. There is a pathway ahead.")
elseif input == "follow path" then
print("You follow the path")
print("A troll appears wielding an axe")
print("What do you want to do? (run away, attack)")
tinput = io.read
if tinput == "attack" then
print("You smack with your sword and it falls dead")
elseif tinput == "run away" then
etc etc etc..
差异是什么?
推荐答案
引用:
而imput〜=exitdo
while imput ~= "exit" do
看起来不正确(我想变量名应该是 input
。这是一个错字吗?)。
doesn't look correct ( I suppose the variable name should be input
. Is it a typo?).
这篇关于关于输入的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!