Test for member function existence?
by Tom Spilman · in Torque Game Engine · 05/07/2005 (5:02 pm) · 4 replies
I'm trying to figure out if the user has implemented a member function on a datablock before i try to execute it and it creates an error in the console output. Simply checking it for a true/false state like a member variable doesn't seem to work. Anyone know how to do this?
About the author
Tom is a programmer and co-owner of Sickhead Games, LLC.
#2
05/10/2005 (12:38 pm)
if(myuser.datablock.myvalue){
myfunction
}else{
dowhateverelseyouwantedtodoifthevaluedidntexist();
}
#3
http://www.garagegames.com/mg/forums/result.thread.php?qt=26790
Maybe you could declare an empty placeholder function instead. If the user later redefines the function, your version will be replaced and no harm done.
(much editing to figure out the href code, which ultimately failed)
05/16/2005 (3:17 am)
I think this requires a change in the engine, and I posted some code a while back in the private forums. No one else seemed to want it, though. :-)http://www.garagegames.com/mg/forums/result.thread.php?qt=26790
Maybe you could declare an empty placeholder function instead. If the user later redefines the function, your version will be replaced and no harm done.
(much editing to figure out the href code, which ultimately failed)
#4
I tried writting a similar function that worked for arbitrary strings passed to it... meaning it would check members... or a member of a member of a memeber... or just global functions. I'm still trying to figure the different places function registration occurs.
05/16/2005 (4:50 pm)
@Andrew - Thanks that helps! I tried writting a similar function that worked for arbitrary strings passed to it... meaning it would check members... or a member of a member of a memeber... or just global functions. I'm still trying to figure the different places function registration occurs.
Torque Owner Todd D. Degani
For checking for a datablock, the tree(); command has that functionality. There is a DataBlock group in the tree that lists all the datablocks. You could probably dive into that code if you have access to it.
For checking if a member function exists, doing