There was an error while loading. Please reload this page.
Create and registers a new metatable with a name in Lua registry and returns it.
RegisterMetatable(name: string) -> mt: table
RegisterMetatable
string
table
name
mt
A code registering a Circle class.
local circlemeta = RegisterMetatable("circle") circlemeta.__index = circlemeta function circlemeta:__tostring() return "circle(" .. tostring(self.origin) .. "; " .. tostring(self.radius) .. ")" end function Circle(center, radius) AssertMetatable(center, "vec2") assert(type(radius) == "number", "vec2") local circle = { origin = center, radius = radius } return setmetatable(circle, circlemeta) end