Posted 13 November 2012 - 04:21 PM
ComputerCraft Version Information: 1.46 Client
Description of Bugs: Lua will not lookup items in metatables when the metatable is in an API
Steps to Reproduce Bug:
I was doing some work on a UI system I'm working on, which heavily uses metatables to do work. However it seems that when a file that defines a metatable is loaded as an API, and a function of that API returns a table that is a child of a metatable, the metatable is not properly used. I have a definition file (the API) that defines Panel and Panel:addComponent. Everything works fine when run from within that file, but when using it outside the API, it seems to break. To test I made a little tester program that I ran both inside and outside the API file (with the API file loaded as an API)
Inside API file (with prinouts)
Outside API file(with printouts)
It seems to know that the metatable exists, but is never looking into it when it can't find something it the base table. Is this intended?
Description of Bugs: Lua will not lookup items in metatables when the metatable is in an API
Steps to Reproduce Bug:
I was doing some work on a UI system I'm working on, which heavily uses metatables to do work. However it seems that when a file that defines a metatable is loaded as an API, and a function of that API returns a table that is a child of a metatable, the metatable is not properly used. I have a definition file (the API) that defines Panel and Panel:addComponent. Everything works fine when run from within that file, but when using it outside the API, it seems to break. To test I made a little tester program that I ran both inside and outside the API file (with the API file loaded as an API)
Inside API file (with prinouts)
p = Panel:create("The Basic Light Machine")
print(getmetatable(p))
--Table:[some numbers]
print(getmetatable(p)==Panel)
--true
print(Panel.addComponent)
--function:[some numbers]
print(p.addComponent)
--function:[some numbers]
print(Panel.components)
--Table:[some numbers]
print(p.components)
--Table:[some numbers]
Outside API file(with printouts)
p = sprkui.Panel:create("The Basic Light Machine")
print(getmetatable(p))
--table:[some numbers]
print(getmetatable(p)==sprkui.Panel)
--true
print(sprkui.Panel.addComponent)
--function:[some numbers]
print(p.addComponent)
--nil
print(sprkui.Panel.components)
--table:[some numbers]
print(p.components)
--nil
It seems to know that the metatable exists, but is never looking into it when it can't find something it the base table. Is this intended?