Closures

hookmetamethod

Hooks a metamethod on a table or object by installing a replacement function.

Syntax

hookmetamethod(object: any, method: string, replacement: function)

Arguments

NameTypeDescription
objectanyObject, table, or drawing value to inspect or change.
methodstringNamecall method name.
replacementfunctionReplacement value or function that should be installed.

Description

Hooks a metamethod on a table or object by installing a replacement function.

Call it with 3 parameter(s): object, method, replacement. The argument table explains which values are required and which ones only refine the behavior.

It does not return data. Treat the call as an action and handle errors around the call site when needed.

Example

Example call with placeholder values.

hookmetamethod(nil, "example", function() end)