Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
while loop not working #463492
12/07/16 22:46
12/07/16 22:46
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I'm wondering if maybe my script is just too long to run properly, because I am getting some strange errors.

Quote:
while(1)
{
if(message_mship < 101)
{
toggle(mship_approach_pan,SHOW);
message_mship += 10;
}
else
{
message_mship = 0;
reset(mship_approach_pan,SHOW);
return;
}

wait(-.25);
}


This while loop gets stuck with the variable "message_mship" set at 11. It should keep looping until it eventually reaches 101, right? It worked in another function for a different flashing panel which is exactly pretty much the same function. I'm wondering if maybe my game's script is just too long and it's somehow forgetting to run through this particular loop.

Is that possible? Other loops in the same .c file seem to work fine though.

I've tried making the wait (1) instead of (-.25) but I get the same results. I've looked for any external function that might be resetting "message_mship" to 1, but can't find any. I've also tried using a different variable, just in case, but that doesn't work either...

Re: while loop not working [Re: Dooley] #463493
12/07/16 22:49
12/07/16 22:49
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I've also rewritten the loop like this...
Quote:

while(message_mship < 101)
{
toggle(mship_approach_pan,SHOW);
message_mship += 10;
wait(-.25);
}

message_mship = 0;
reset(mship_approach_pan,SHOW);

Re: while loop not working [Re: Dooley] #463497
12/08/16 03:59
12/08/16 03:59
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
Chicago, IL
I figured it out ...

The function that called the function with the loop ends before the loop finishes, and that's why it gets stuck.

I'm pretty sure I encountered this before, and did not realize it until I found the cause.


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