The question is simple. How do I see what arguments a function has been called with without overriding it?
If you are doing this for debugging then you could use [url=http://pgl.yoyo.org/luai/i/debug.sethook]debug.sethook[/url], [url=http://pgl.yoyo.org/luai/i/debug.getinfo]debug.getinfo[/url] and [url=http://pgl.yoyo.org/luai/i/debug.getlocal]debug.getlocal[/url] (function parameters are just local values that are pushed onto the stack before a function call).
[lua]debug.sethook(function()
local inf = debug.getinfo(2)
if inf.func == func then -- if inf.name == "func_name" then
for i=1, inf.nparams do
print("param: ", debug.getlocal(2, i))
end
end
end, "c")[/lua]
Replace func with the function you want to check the parameters of, or use the commented line and use the function name as a string.
[editline]27th May 2013[/editline]
This is assuming you can use the debug hook in garrysmod?
[QUOTE=MakeR;40799853]If you are doing this for debugging then you could use [url=http://pgl.yoyo.org/luai/i/debug.sethook]debug.sethook[/url], [url=http://pgl.yoyo.org/luai/i/debug.getinfo]debug.getinfo[/url] and [url=http://pgl.yoyo.org/luai/i/debug.getlocal]debug.getlocal[/url] (function parameters are just local values that are pushed onto the stack before a function call).
[lua]debug.sethook(function()
local inf = debug.getinfo(2)
if inf.func == func then -- if inf.name == "func_name" then
for i=1, inf.nparams do
print("param: ", debug.getlocal(2, i))
end
end
end, "c")[/lua]
Replace func with the function you want to check the parameters of, or use the commented line and use the function name as a string.
[editline]27th May 2013[/editline]
This is assuming you can use the debug hook in garrysmod?[/QUOTE]
Ah, you made my day. I tried using debug aswell, but never knew getlocal can be used to acquire function params.
You have my gratitude.
Sorry, you need to Log In to post a reply to this thread.