hookmetamethod
Notes on hookmetamethod
hookmetamethod
can be safely implemented from within Luau, as long as hookfunction
is already properly implemented in C++.
hookmetamethod
takes any Luau object that can have a metatable, and attempts to hook the specified metamethod of the object. Internally, it essentially uses hookfunction
to hook specific metamethods.
function hookmetamethod(object: { any } | userdata, metamethodName: string, hook: (...any) -> (...any)): (...any) -> (...any)
Parameters
Parameter | Description |
---|---|
object |
The object which has a metatable. |
metamethodName |
The name of the metamethod to hook. |
hook |
The function that will be used as a hook. |
Example
Easily hooking metamethods with hookmetamethod | |
---|---|