Game Development Community

Does a field exist?

by Dumbledore · in Torque Game Engine · 08/20/2008 (4:53 pm) · 1 replies

How do you find out if a dynamic field was initialized in script?

Ex.
%obj.field1 = 0;  
if ( exists(%obj.field1) )
{
     echo("Field exists."); 
}

if ( exists(%obj.fake) )
{
     echo("Field does not exist.");
}

I know dynamic fields get initialized to zero... but what if zero is a valid value in the context? Testing for zero won't work for me.

#1
08/20/2008 (5:27 pm)
Test against an empty string, eg
if ( %obj.field1 $= "" )
{
   // is not used
}