July 2018
Beginner
202 pages
5h 42m
English
You can both test whether a table has a meta table and retrieve the said meta table with the int lua_getmetatable (lua_State*, int) function. The first argument to this function is the Lua state it affects, and the second argument is the index of a table on the stack. If the table at the specified index has no meta table, the lua_getmetatable function returns 0 and does not push anything onto the stack. If the table at the specified index does have a meta table, the lua_getmetatable function will return 1 and push the meta table onto the stack.
You can assign a meta table to an existing table with the int lua_setmetatable (lua_State*, int) function. This function takes the Lua state it affects as its first argument, and the index ...