Game Development Community

Script-side test for function existence before calling ?

by Orion Elenzil · in Torque Game Engine · 07/24/2007 (1:46 pm) · 3 replies

Hey folks,

does anyone know of a way in torquescript to test for the existence of a function ?

it's okay to just go ahead and call() or exec() it,
but if the function doesn't exist it prints a warning to the console,
which is a *good* thing,
except in this case i know ahead of time that the function may not exist.

or any suggestions where to start writing such a ConsoleFunction.

tia,
orion

#1
07/24/2007 (2:15 pm)
Use the script funtion isFunction . It is defined consoleFunctions.cc if you want more detail.
#2
07/24/2007 (2:23 pm)
Thanks Simon.

for the curious, to expose that guy to script,
add the following to consoleFunctions.cc, near "ConsoleFunction(call...":
ConsoleFunction(isFunction, bool, 2, 2, "isFunction(funcName)")
{
   return Con::isFunction(argv[1]);
}
#3
07/24/2007 (2:27 pm)
Ah wait - that must be already included in something more recent than tge 1.3..
heh.