Do metatables work on tables? I was thinking something like:
01 | local tab = { } |
02 | local metaTab = { |
03 | __index = function (tab, i) |
04 | print (tab, i) |
05 | end ) |
06 | } |
07 | function tab:test(what) |
08 | print (what) |
09 | end |
10 | setmetatable (tab, metaTab) |
11 | tab:test( "wat" ) |
Yes. In Lua 5.2+, that's the only thing metatables work with. In Lua 5.1 (what Roblox uses), metatables can be used with userdatas and tables.