Would it be possible to allow the PreHook and PostHook function to return arguments from the hook function?
Right now it does only accept a return true which prevents the original from running.
Something like this: (untested)
Lua Code:
local newFn = function(...)
local ret = {hookFunction(...)}
if(not ret[1]) then
return existingFn(...)
else
table.remove(ret, 1)
return unpack(ret)
end
end
It would also be cool if the post hook function could receive the return values from the hooked function.
e.g.: (untested)
Lua Code:
local newFn = function(...)
local ret1 = {existingFn(...)}
local ret2 = {hookFunction(ret1, ...)}
if(ret2[1]) then
table.remove(ret2, 1)
return unpack(ret2)
end
return unpack(ret1)
end