Game Development Community

Just out of interest: IF supports AND

by Chris Schirlinger · in Torque Game Builder · 05/27/2006 (7:37 pm) · 3 replies

In case people don't know (I didn't and I haven't seen any documentation about it) it seems as if Torque script IF statement supports AND's and OR's

Example:

if (%x > 100 && %x < 200)
{
// TRUE if X is greater than 100 *AND* smaller than 200 (ie, Between 100 and 200)
}

if (%y < 100 || %y > 200)
{
// TRUE if y is smaller than 100 *OR* Y is greater than 200
}


You can also use more complex equations

if (%x > 100 && %x < 200 && %y > 150 && %y < 250)
{
// TRUE if inside the rectangle defined by (100, 150) - (200, 250)
}

I am not sure if there are any issues or what sort rules used (for example how is the following interpreted - ((x% > 100 && X% < 200) || (%y == 100)) but the other examples above seem to work fine for me

#1
05/27/2006 (9:41 pm)
Thank you! I didn't know this either. Very helpful.
#2
05/28/2006 (12:59 am)
The torquescript logical operators are kinda like C++ I think
tdn.garagegames.com/wiki/TorqueScript_Quick_Reference#Operators_in_TorqueScript_...
#3
05/28/2006 (1:29 am)
Quote:The torquescript logical operators are kinda like C++ I think
Yes, that's what made me try the && and ||

I can't say I've seen anyone use them though and I've read a lot of examples. Several even have to produce convoluted nested IF's when they could have used a && so it's not in general use