if( $leader.classN"> How do I check a for specific text in a field? | Torque Game Engine | Forums | Community | GarageGames.com

Game Development Community

How do I check a for specific text in a field?

by Nicolai Dutka · in Torque Game Engine · 09/13/2007 (7:41 pm) · 4 replies

I think just by reading the following code in my console.log file, you should be able to see what I am trying to do. None of this works though... does anyone know why?

==>if( $leader.className == "warlock" ) echo("word");
word
==>if( $leader.className == "warlock" ) echo("word");
word
==>if( $leader.className == "Warloc" ) echo("word");
word
==>if( $leader.className == "Wizard" ) echo("word");
word
==>if( $leader.className $= "Wizard" ) echo("word");
==>if( $leader.className $= "warlock" ) echo("word");
==>if( $leader.className $= "warlock" ) echo("word");
==>if( $leader.className %= "warlock" ) echo("word");

$leader is referring to the currently controlled player character and ALL of the players have a ".className" added to them on creation.

Thanks!

#1
09/14/2007 (1:32 am)
You're not comparing strings in your first few, so you shouldn't even have to try that. Use:

if( $leader.className $= "warlock" )

That's correct. If it doesn't return true then there's something wrong with your className.
#2
09/14/2007 (1:15 pm)
As you can plainly see by the 3rd to last and 2nd to last lines in that code, I already tried that. It isn't working.
#3
09/14/2007 (1:27 pm)
Then echo out the values of $leader.className yourself (or use Torsion and put them on a watch), and find out what values are actually being compared.

$= is the operator you want to use, not == or %= (%= is not an operator).
#4
09/14/2007 (2:58 pm)
I actually am trying these on my own with the console. I only copy/pasted from the console.log because it was faster. :P

So I am doing it right... I guess I'll have to just mess with it some more...