Say I have a table with its metatable having a metatable within it:
["speed"]: 40,
["__index"]:
["name"]: "ball",
["__index"]:
["this"]: "it doesn't know this exists"
How can I make it such that I can find “this” all the way from the original table? It doesn’t seem to be working
1 Like
BlxIsHere
(BlxIsHere)
#2
probably try changing the name of the second __index
LerpSoh
(MattressBuyer)
#3
Something like this?
local a = setmetatable({
speed = 40
}, {
__index = setmetatable({
name = "ball"
},
{
__index = {
this = "it does know this exists"
}
})
})
print(a.this)
0786ideal
(ideal)
#4
you need to set metatable, not insert another table
local t = {
Orange = 5
}
t.__index = t
local mt1 = {
Lemon = 5
}
mt1.__index = t
local mt2 = {
Apple = 3
}
mt2.__index = mt1