You can make any table inherit from the Table class.
But if the table already has a metatable set, you will get an error.
local Table = dofile("table_class.lua") -- /data/script/table_class.lua
local scripts = Table:new(Scripts) -- the global _G.Scripts table already has a metatable set
Here is the error message:
You would have to explicitly state that you want to override the existing metatable (not recommended).
local Table = dofile("table_class.lua")
local mytable = setmetatable({}, {})
Table:new(mytable, true) -- override existing metatable, no error
mytable:print(echo, nil, "mytable", nil, nil)
Instead, don't make the table inherit and pass it to the Table.print function directly (as we did above with _G).
Table.print(
Scripts -- root
echo, -- log function
nil, -- no blocked tables
"Scripts", -- root name
" ", -- indentation
nil -- no limit to maxdepth
)