Game Development Community

Checking variables for negative values?

by Nicolai Dutka · in Torque Game Builder · 03/31/2008 (7:48 pm) · 1 replies

I need to check the position of a Gui object and move it by -1 each time I update it until it reaches -800. ( I am sliding it slowly out of view to the left)

I can get it from 'out of view on the right' (position 800,250) to the far left (position 0,250) and one past that (position -1,250). From there, I can't get it to go any farther because the code doesn't check for negative number properly. Here is what I have:

if(%x>0) schedule(10,0,messageText,%message); //moves the text
  if(%x==0) schedule(1500,0,clearMessage,%message); //text reached the edge. have a short wait, then clear it off

function clearMessage(%message)
{
  messageText.setText("<just:center><font:arial bold:44><color:ffffff><shadow:2:2><shadowcolor:000000>"@ %message);
  %x = getWord(messageText.getPosition(),0) - 1;
  messageText.setPosition(%x,250);
  if(%x>0-800) schedule(50,0,messageText,%message);
  if(%x==0-800)
  {
    messageText.setText("");
    messageText.setPosition(800,250);
  }
}

I realize I cannot say "if(%x>0-800)" and have it work, but I never learned how to do this and it was my best guess after just trying "if(%x>-800)" which actually caused an error...

#1
04/02/2008 (1:10 am)
I am SOOOOO sorry! I must've been up late one night when I posted this!

if(%x>-800) <--- Works perfectly fine....