Casting String to Float in TS
by Tom Eastman (Eastbeast314) · in Torque Game Builder · 06/18/2006 (10:00 pm) · 2 replies
I feel like such a fool not being able to find this in the resources, but I've got a problem that I think is caused by casting.
I'm traversing a List using getWord. If I echo out the word I want, it's all nice and stringy (and greater than 0.85), but when I do the following comparison, it ALWAYS fails. So, my only thought is that the left side is being evaluated as a string. (Perhaps it's something else, even simpler than a casting problem). So, would someone please tell me how casting is done in TorqueScript?
I get "no contact" every collision callback. Thanks in advance!
I'm traversing a List using getWord. If I echo out the word I want, it's all nice and stringy (and greater than 0.85), but when I do the following comparison, it ALWAYS fails. So, my only thought is that the left side is being evaluated as a string. (Perhaps it's something else, even simpler than a casting problem). So, would someone please tell me how casting is done in TorqueScript?
if( getWord(%contacts, %a + 1) > 0.85){
%this.hasContact = true;
echo("Contact!");
}else{
%this.hasContact = false;
echo("no contact");
}I get "no contact" every collision callback. Thanks in advance!
#2
I figured out what it was. Wasn't a casting problem at all (not surprising). I was simply thinking that I had echoed out the word I was comparing when I was actually showing the getLocalPoint transformation of that point. Quite the foolish mistake.
Would be nice if there was some mention of there not being casting in the reference docs where it talks about data types, though.
Thanks for the response!
06/19/2006 (7:44 am)
*sigh*I figured out what it was. Wasn't a casting problem at all (not surprising). I was simply thinking that I had echoed out the word I was comparing when I was actually showing the getLocalPoint transformation of that point. Quite the foolish mistake.
Would be nice if there was some mention of there not being casting in the reference docs where it talks about data types, though.
Thanks for the response!
Torque Owner Jason McIntosh
I tried something like that in the console and it worked.
Those statements evaluate correctly for me in RC3.