So I know that lua will look to a table's metatable if it doesn't contain the variable I reference, but it seems wrong that when I attempt to set a variable that doesn't exist yet in a table it sets it in the metatable instead.
Heres an example of what i mean
a = {__index = {tbl1 = {var = 1}, tbl2 = {var = 2}}}
b = setmetatable({}, a)
print(b.tbl1.var, a.__index.tbl1.var)
b.tbl1.var = 2
print(b.tbl1.var, a.__index.tbl1.var)
In this code it will replace the metatables variable instead of setting it in the table im referencing.
However this does not occur with this code
a = {__index = {4, 5, 6}}
b = setmetatable({}, a)
print(b[1], a.__index[1])
b[1] = 2
print(b[1], a.__index[1])
Is there more work needed when using metatables and nested tables? Or is there a way around this?