Game Development Community

Class Comparison Issues [T2D] [Solved]

by Timi · in Technical Issues · 11/09/2010 (11:39 pm) · 3 replies

There seems to be something wrong with comparing an object's class via code in Torque 2D. It returns true every time.

Within a collision I have this:
echo (%object.class);
	
	if (%object.class == "goodClass") {
		echo ("This is a good class!");
	}

This will output:
badClass
This is a good class!
Which of course is not true at all. Am I doing something wrong?

#1
11/10/2010 (2:07 am)
When comparing strings you need to use this

if (%object.class $= "goodClass") 
{  
   echo ("This is a good class!");  
}
#2
11/10/2010 (2:14 am)
Oh my. It's always the tiny things, you know? Single character differences.
Thank you very much =)
#3
11/10/2010 (2:42 am)
Aun, what happened to Torque-motion.com?