diff options
-rw-r--r-- | server/src/vm/source.lua | 8 | ||||
-rw-r--r-- | server/src/vm/value.lua | 17 |
2 files changed, 23 insertions, 2 deletions
diff --git a/server/src/vm/source.lua b/server/src/vm/source.lua index 59d5d66d..3884af20 100644 --- a/server/src/vm/source.lua +++ b/server/src/vm/source.lua @@ -64,6 +64,14 @@ function mt:bindCall(args) end end +function mt:bindMetatable(meta) + if meta then + self._bindMetatable = meta + else + return self._bindMetatable + end +end + function mt:action() return self._action end diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua index f731892b..29419966 100644 --- a/server/src/vm/value.lua +++ b/server/src/vm/value.lua @@ -192,11 +192,24 @@ function mt:getChild(index, source) end function mt:setMetaTable(metatable) - self._meta = metatable + local source = metatable:getSource() + if not source then + return + end + source:bindMetatable(metatable) + self._meta = metatable.source end function mt:getMetaTable() - return self._meta + if not self._meta then + return nil + end + local metaSource = listMgr.get(self._meta) + if not metaSource then + self._meta = nil + return nil + end + return metaSource:bindMetatable() end function mt:getMetaMethod(name) |