Hey there, I have an issue where I have a meta table called Meta which is a metatable for another metatable called Meta2, and Meta2 is the meta table for a table called SimplyNotMeta, when I am doing SimplyNotMeta["Pizza] = "Italy
, it is not firing the __newindex
metamethod in metatable Meta, Why’s that, heres code:
print("Test Started")
local Meta = {
debounce = false
}
Meta.__newindex = function(SimplyNotMeta, ind, val)
if(Meta.debounce) then return end
print("Called __newindex, Setting value of table "..tostring(SimplyNotMeta).." at index "..ind.." with value "..val)
Meta.debounce = true
SimplyNotMeta[ind] = val
Meta.debounce = false
end
local Meta2 = {}
Meta2.__index = Meta2
setmetatable(Meta2, Meta)
local SimplyNotMeta = {}
setmetatable(SimplyNotMeta, Meta2)
print("Setting val starting...")
SimplyNotMeta["Pizza"] = "Italy"
SimplyNotMeta["Taco"] = "Mexico"
SimplyNotMeta[1] = "Pizza"
SimplyNotMeta[2] = "Taco"
print("Setting val ended!")
It should print like “Called __newindex…” in output, but it isnt outputting this at all,
Please mention what could I improve here, Thank you!