我是Lua的新手,我在打印数组值时遇到问题.
谷歌搜索后,我来到这里,但它只打印数组中的最后一项,'armor'
.我究竟做错了什么?另外我怎么能在每个项目后添加一个逗号?
local items = {'bread', 'shield', 'boots', 'legs', 'armor'}
for i, item in ipairs(items) do
text = item
end
William:Speak("I am interested in the following: ".. text)
Run Code Online (Sandbox Code Playgroud)
使用逗号进行串联的较短方法也可以是(source):
local items = {'bread', 'shield', 'boots', 'legs', 'armor'}
conc = table.concat(items, ",")
William:speak("I am interested in the following: ".. conc)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
64 次 |
最近记录: |