-2

Is there a way to call metatable methods inside the metatable itself? For example

local t = {}
local mt = {
    __index = {
        dog = function() print("bark") end,
        sound = function() t:dog() end
 }
}

setmetatable(t,mt)

t:Sound()

raises this error:

attempt to call method 'Sound' (a nil value)

user3204810
  • 323
  • 6
  • 16

1 Answers1

5

because you don't have Sound. Only sound.

FareakyGnome
  • 134
  • 4