|
|
SGT_FW
by Aku_Aku. 11/30/26 08:19
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 registered members (AndrewAMD, TipmyPip, EvanTJ, EW_bytes, JeyKey II, krishna),
12,405
guests, and 1
spider. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
whats wrong with this if statement?
#217072
07/21/08 07:13
07/21/08 07:13
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Okay for some reason something is terribly wrong with this while loop, why?
var destination[3] = {0};
var oldDest[3] = {0};
while(1)
{wait(1);
destination[0] = my.destX;
destination[1] = my.destY;
if(oldDest[0]!=destination[0]||oldDest[1]!=destination[1]) //use to send destionation coords
{
oldDest[0] = destination[0];
oldDest[1] = destination[1];
pMyZoneDest[0] = my.destX;
pMyZoneDest[1] = my.destY;
send_var(pMyZoneDest);
// beep();
}
}
The if statement is always true... even when my.destX and my.destY DONT CHANGE O_O. Whats going on? I think i'm assigning something wrong...
Last edited by PrenceOfDarkness; 07/21/08 07:15.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: whats wrong with this if statement?
[Re: PrenceOfDarkness]
#217075
07/21/08 07:56
07/21/08 07:56
|
mercuryus
Unregistered
|
mercuryus
Unregistered
|
try to init your arrays complete...
var destination[3] = {0,0,0}; var oldDest[3] = {0,0,0};
|
|
|
Re: whats wrong with this if statement?
[Re: PrenceOfDarkness]
#218529
07/29/08 07:00
07/29/08 07:00
|
Joined: Mar 2006
Posts: 15 Kansas, USA
quantum69
Newbie
|
Newbie
Joined: Mar 2006
Posts: 15
Kansas, USA
|
Just a thought, to be sure you're don't run into order precendence issues, surround your main comparisons in their own parenthesis to avoid confusion.
( (oldDest[0] != destination[0]) || (oldDest[1] != destination[1]) )
You want it to update the location when new coordinates are given, otherwise you want it to sit there and wait. Try the parenthesis first and see if it's not precendence related first.
If there's the possibility that your two locals are going out of scope try making them static to see if that keeps oldDest valid from wait to wait.
------------------------------------ Quantum Mechanic Better living at the subatomic level
|
|
|
|
|
|
|