Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (TedMar, VoroneTZ), 1,317 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Serious User
PrenceOfDarkness  Offline OP
Serious User

Joined: Aug 2004
Posts: 1,305
New York
Okay for some reason something is terribly wrong with this while loop, why?
Code:
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

M
mercuryus
Unregistered
mercuryus
Unregistered
M



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: ] #218479
07/28/08 21:15
07/28/08 21:15
Joined: Jul 2008
Posts: 26
Norway
H
Harstad Offline
Newbie
Harstad  Offline
Newbie
H

Joined: Jul 2008
Posts: 26
Norway
I dont know alot, and I'm a total newbie to this, but what if you try putting wait (1); after beep; ?

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
Q
quantum69 Offline
Newbie
quantum69  Offline
Newbie
Q

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

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1