如何根据属性获取对象(在这种情况下,是分配给它的ID)?以下是我目前正在处理的代码示例。
Ped = {} -- Ped class.
Ped.__index = Ped
gPedID = 0
gPedAdditionalID = "Shop"
function Ped.create(_type, _skin, _x, _y, _z)
local _ped = {}
setmetatable(_ped,Ped)
_ped.oType = _type
_ped.pedElement = createPed(_skin, _x, _y, _z)
_ped.ID = gPedID
gPedID = gPedID + 1
return _ped
end
function pedID(player, command)
-- code to grab the object based on the object.ID
end
我试图创建一个引用该对象的表,即:
generictable[_ped.ID] = _ped
但无济于事,我猜测原因是因为它只复制了地址,而不是实际参考。
非常感谢帮助,谢谢!