【发布时间】:2022-01-11 04:58:52
【问题描述】:
local ents = {
GetLocalPlayer = function()
local tbl = {
localplayer = {"Ava", "1", {213,234,234}},
GetIndex = function(self)
return self.localplayer[2]
end,
}
setmetatable(tbl, getmetatable(tbl.localplayer))
return tbl
end
}
local function main()
print(ents.GetLocalPlayer()[2])
end
main() 打印返回零。但是,如果我要执行 ents.GetLocalPlayer():GetIndex(),它会返回 1。
想法是如果我不做GetIndex()之类的事情,则默认返回值为localplayer
【问题讨论】: