Finding Argument Names for a Function

I’m trying to write a script that will consequently catalog every function along with its arguments for a simplified Lua editor somewhat like Scratch in Garry’s Mod.I already have a loop that catalogs each function, but what I need is a way to catalog their arguments. One way I thought of would be debug.sethook() with an “l” mask which checks for function definition and saves arguments, however this wouldn’t work due to complications with call order and local functions and that fun stuff.

So how would I find the parameters for a function without manually documenting them one at a time myself? Just retrieving the number of arguments would suit my purpose.

debug.getinfo will give you the file and the position that the function was delcared. You could use that to read the .lua file and parse the arguments.

How would I select a specific line to read?

[lua]
local tbl = string.Explode("
", file.Read(“lua/includes/modules/cleanup.lua”, “GAME”))

PrintTable( tbl )
[/lua]

Using something like this I presume.

The position is a range of lines that the function is in.

Keep in mind that this doesn’t work for C functions, so you will have to manually fill those ones out.