setmetatable(table, metatable)

Sets the metatable for the given table. (You cannot change the metatable of a userdata type from Lua, only from C.) If metatable is null, removes the metatable of the given table. If the original metatable has a "__metatable" field, raises an error. This function returns table.