Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (TedMar), 1,420 guests, and 3 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
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