CLEO Help How do i use proper REPEAT.. UNTIL?

CLEO related
Status
Not open for further replies.

GidanDaniel

Active member
Joined
Feb 22, 2014
Messages
28
Reaction score
0
As Title said, i need help how to use proper REPEAT.. UNTIL :table_flip:

i tried to do this
Code:
Repeat
wait 250
actor.health($PLAYER_ACTOR) = 25
wait 250
actor.health($PLAYER_ACTOR) = 50
wait 250
actor.health($PLAYER_ACTOR) = 75
wait 250
actor.health($PLAYER_ACTOR) = 100
until 0AB0: key_pressed 49 OR actor.dead($PLAYER_ACTOR) //repeat should be stopped if i press '1' or i'm dead

but it seems 'UNTIL' cannot break loop statement when conditions applied, So.. it will repeat the code until i close my GTA  :angry:

Any solutions to make 'UNTIL' work? :imoverit:
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,125
Reaction score
149
Hi, as far as I know the condition (until) can't be altered by "OR" or "AND" but by using checks within the loop you can bypass that limitation.

Code:
31@ = 0
repeat 
wait 0
if or
0AB0: key_pressed 49
actor.dead($PLAYER_ACTOR)
then
31@ = 1
end
wait 250
actor.health($PLAYER_ACTOR) = 25
wait 250
actor.health($PLAYER_ACTOR) = 50
wait 250
actor.health($PLAYER_ACTOR) = 75
wait 250
actor.health($PLAYER_ACTOR) = 100
until 31@ == 1

Code:
if or
0AB0: key_pressed 49
actor.dead($PLAYER_ACTOR)
then
31@ = 1
end
You could also copy/paste this part to make sure the checks are done frequently between "wait 250"
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
226
Location
( ͡° ͜ʖ ͡°)
You can not use OR. This is wrong:


Code:
repeat

until <A> OR <B>


This is correct:

Code:
repeat

until <A>
Do not use repeat until in a script like you made. Instead use this:

Code:
WHILE TRUE
WAIT 0
END


add a toggle to it and then add your health script into the loop like this:

Code:
{$CLEO .cs}
0000:

0@ = 0
WHILE TRUE
    WAIT 0
    if or
    0ADC: TYPING "MOD"    
    0AB0: 88
    then
        if 
        0@ == 0
        then
            0@ = 1
            018C: play_sound 1083 at 0.0 0.0 0.0
            0ACD: show_text_highpriority "MOD ENABLED" time 1337
        else
            0@ = 0
            018C: play_sound 1084 at 0.0 0.0 0.0
            0ACD: show_text_highpriority "MOD DISABLED" time 1337  
        end
        WAIT 350
    end
    if and
    not actor.Dead($PLAYER_ACTOR) // so if the toggle is on, and you are not dead it will heal you to 100 hp in a loop
    0@ == 1
    then    
        wait 250
        actor.health($PLAYER_ACTOR) = 25
        wait 250
        actor.health($PLAYER_ACTOR) = 50
        wait 250
        actor.health($PLAYER_ACTOR) = 75
        wait 250
        actor.health($PLAYER_ACTOR) = 100
    end
END
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
It stops when you press key 49, but because of the multiple 'wait' you need to keep it pressed until it reaches the end.
You could also use break. But in your case you better use Opie example.

This could work too, instead of wait it checks every ms for the break condition.
Code:
32@ = 0
0@ = 25
repeat
    wait 0
    
    if or
        0AB0: 49
        actor.dead($PLAYER_ACTOR)
    then BREAK
    end 
    
    if 32@ >= 250
    then 
        actor.health($PLAYER_ACTOR) = 0@
        0@ += 25
        32@ = 0
        if 0@ > 100
        then 0@ = 25
        end
    end    
until false
 

GidanDaniel

Active member
Joined
Feb 22, 2014
Messages
28
Reaction score
0
Thanks for your help, i now know how to loop things but.. i still don't get it springfield about your code, what is '32@' mean? :forever_hurra:
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
32@ and 33@ are timers, each milisecond their value increases by one. They're useful for timing checks.

ex;

Code:
32@ = 0
repeat
    wait 0
until 32@ >= 5000
0AD1: "5seconds have passed" 1000
 
Status
Not open for further replies.
Top