Page 1 of 1

How to know the installed user functions?

Posted: Wed Jan 19, 2011 7:39 am
by jduartedj
I'd like to know how to detect if a certain user function is installed because if it isn't then an error comes up but doing:

Code: Select all

if gameText then
   gameText("I exist","WARNING")
end
doesn't make it because the function returns nil anyway isn't it?

is there a variable with all the installed user functions? like settings.addons["gameText"] or settings.uf["gameText"] ? that records either the uf file names or the function names themselves?

Re: How to know the installed user functions?

Posted: Wed Jan 19, 2011 1:20 pm
by rock5
No, that should work. The only time a value will return false is if it is "false" or "nil". A function is not nil. You don't have to worry about what the function returns because you are not executing it, you are just checking if it exists by treating it as an object. For it to be executed you have to include the brackets then you would be dealing with what it returns.

Re: How to know the installed user functions?

Posted: Wed Jan 19, 2011 6:27 pm
by jduartedj
will further test it!