【发布时间】:2017-03-23 21:24:40
【问题描述】:
我有一个带有元表的 userdata 值,我想像这样添加另一个元表:
local obj = Game:create_object() --Obj now contains userdaa
print(obj:get_x()) --Use method in metatable of obj
--I would like to do something like this:
local mt = {name = "test"}
mt.__index = mt
setmetatable(obj, mt)
print(obj.name)
--And still have the methods from the beginning
print(obj:get_x())
这有可能吗?如果没有,有什么替代方案?
【问题讨论】: