Legacy GM increasing repeat statement from within?

D

Dengar

Guest
can i extend a repeat statement from within itself?

i tried this as a test but it doesn't work.
Code:
tt = ""  //test message, number of characters will indicate number of loops
vv=2;  //times to repeat
ti = 1; //this is so i only try increasing the loop once

repeat (vv)
{
tt = tt + "G";
if ti = 1 {vv+=1; ti=0;}
}

show_message(tt);
 

Freddy Jones

Your Main Detective
There is no way to elongate the number of cycles a repeat statement does. Though, like any other loop, it can be cut short using the break statement.

Repeat is essentially like writing a for loop except the condition being checked in the loop is checked by value, not reference.

Have you looked into other looping alternatives such as while, do-until, or for? They are more dynamic and flexible than repeat.
 
D

Dengar

Guest
There is no way to elongate the number of cycles a repeat statement does. Though, like any other loop, it can be cut short using the break statement.

Repeat is essentially like writing a for loop except the condition being checked in the loop is checked by value, not reference.

Have you looked into other looping alternatives such as while, do-until, or for? They are more dynamic and flexible than repeat.
do until statement works perfect. thanks for pointing out the obvious for me :)
 

TheouAegis

Member
The repeat loop is the only loop whose condition is set at the START of the loop. This makes it useful for any loop where you may change the variables used in the criteria but not want to change the duration itself.

repeat instance_count
instance_create(irandom(room_width), irandom(room_height), obj_powerup);

In any other loop, that cause the program to crash.
 
Top