Getting a function's parameters on a module

Hello people. So basically I’ve started making an admin command bar system, and I need a way to get the parameters of a function that you send.

function module.new(name: string, description: string, callback: (any) -> ()) -- I need to get the parameters of the 'Callback' function, and see their type.

I have never seen anybody asking this before, so I’m making a post to see if theres any possible way of doing this, without having to send the arguments as an appart parameter.

you cant

you have to put the arguments along with the function manually

2 Likes

You can only get the number of parameters a function has, but not their name or type. Even then, you can only get that information inside of the function, so it’s not very helpful.

local function foo(a, b, c)
	print(debug.info(1, "a")) --> 3, false
end

local function bar(a, b, c, d, e, ...)
	print(debug.info(1, "a")) --> 5, true
end

foo()
bar()

Try doing it how Cmdr does it, with two or three separate modules per command.

2 Likes

Are you trying to achieve something like this?

Thank you, I will try looking into the Cmdr module.