- Joined
- Feb 7, 2020
- Messages
- 398
I can't wrap my head around what metamethod to use for this, or how the code would look, after much trial and error:
I'd like to take a table, say "myClass", and wrap every method called from it with another function (that preserves the original function's arguments when used in the wrapper).
e.g.
If that made sense, do any Lua gurus have an example of this concept available? The online tutorials I tried to follow were a bit unworldly (incrementing random integers, etc.).
I'd like to take a table, say "myClass", and wrap every method called from it with another function (that preserves the original function's arguments when used in the wrapper).
e.g.
Lua:
myObj = myClass:new()
myObj:doSomeStuff(someArg)
myObj:doSomeOtherStuff(myArg)
myObj:doSomeMoreStuff(myOtherArg)
-- do a hidden wrap of each i.e. someWrapper(doSomeStuff(someArg)) and so on, without having to WET
If that made sense, do any Lua gurus have an example of this concept available? The online tutorials I tried to follow were a bit unworldly (incrementing random integers, etc.).
Last edited: