-
-
Notifications
You must be signed in to change notification settings - Fork 10
GetMetatable
Jérôme Leclercq edited this page Dec 8, 2020
·
2 revisions
API: GetMetatable
Retrieves a global metatable, previously registered with RegisterMetatable, by its name.
GetMetatable(name: string) -> mt: table | nil
-
name: The metatable identifier/name.
-
mt: The metatable ornilif no metatable was registered with this name.
A code which adds a DotProduct method to Vec2.
local vec2meta = GetMetatable("vec2")
function vec2meta:DotProduct(vec)
AssertMetatable(vec, "vec2")
return self.x * vec.x + self.y * vec.y
end