【发布时间】:2021-02-28 19:31:54
【问题描述】:
我想更改原始变量,以便函数打印不同的答案。我是 Lua 新手,这可能吗?我该怎么做?
这是我的代码:
io.write("Hello, what is your first player's name? ")
local name = io.read()
io.write('How old is Player 1? ')
local age = io.read()
function Recall()
print("Your player's name: " ,name, "\nYour player's age: " ,age, "\n")
end
Recall()
io.write("What is your second player's name? ")
local name = io.read()
io.write('How old is Player 2? ')
local age = io.read()
Recall()
当我第二次调用该函数时,它会在第一个输入中打印姓名和年龄。有什么建议吗?
【问题讨论】:
标签: function variables lua var