【发布时间】:2020-06-25 02:43:39
【问题描述】:
我正在尝试构建一个表并在每次我得到一个尚未在表中的返回值时添加到它。所以基本上我到目前为止所拥有的根本不起作用。我是 LUA 新手,但不是一般的编程新手。
local DB = {}
local DBsize = 0
function test()
local classIndex = select(3, UnitClass("player")) -- This isn't the real function, just a sample
local cifound = False
if classIndex then
if DBsize > 0 then
for y = 1, DBsize do
if DB[y] == classIndex then
cifound = True
end
end
end
if not cifound then
DBsize = DBsize + 1
DB[DBsize] = classIndex
end
end
end
然后我尝试使用另一个函数来打印表格的内容:
local x = 0
print(DBsize)
for x = 1, DBsize do
print(DB[x])
end
任何帮助将不胜感激
【问题讨论】:
-
Lua*