Hello, today i will explain "WHILE" statement
for "WHILE TRUE" i think it means while everything is = 1 = true ( we learned 1 means true , 0 means false)then run the script.
here is our simple script:
for me i don't see a very big use for while true , but it may be handful with commands (http://ugbase.eu/tutorials/)read-commands-and-do-something-about-tut-open-source-codes/) so if we used while true means (and for example) if 31@ == 1 but even with that we don't really need it we can always replace it by if statement
but while true is useful in loops while like 21@ = 1
but now for the big thing and the best use of while statement
the following script is new for you , the idea of it , is recovering health while you are holding key 1
so this is our script:
so now "while" means while key 1 pressed run the script
we use while in our life , and it is same here
so while key 1 pressed = while we are holding key 1 run the script
this is what while means.
so while this condition is true do the following
and after every while we need wait 0
and we need the closer end just like then
this is while code:
one thing more is if we want while not this condition is true
we use :
and congratulations you just made a health generator hack![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
thanks for following my tutorials.
if i helped you please hit the thanks button and the little heart(rep.) under my name so you can make me more trusted for users so they can reach me easily.
for "WHILE TRUE" i think it means while everything is = 1 = true ( we learned 1 means true , 0 means false)then run the script.
here is our simple script:
Code:
:start
wait 0
WHILE TRUE // in capital or small letters (it doesn't matter)
wait 0 // after every "WHILE" we need "wait 0" to avoid crashing
if
0AB0: key_pressed 49 //1
then //every "then" needs "end" remember?
0AD1: show_formatted_text_highpriority "YOU PRESSED 1" time 1000
end //this end is for "then" statement
END //this big "END" is for "WHILE" , so "while" get closed,, every while needs closer which is "end"
// we don't need to use big END because end = END , so capitals doesn't matter but we use END with capital so we can read the script better (so we can notice that this end belongs to WHILE)
jump @start
for me i don't see a very big use for while true , but it may be handful with commands (http://ugbase.eu/tutorials/)read-commands-and-do-something-about-tut-open-source-codes/) so if we used while true means (and for example) if 31@ == 1 but even with that we don't really need it we can always replace it by if statement
but while true is useful in loops while like 21@ = 1
Code:
:first
wait 0
if and
056D: actor $PLAYER_ACTOR defined
//0AB0: key_pressed 71 //g
//0AB0: key_pressed 72 //h
then
0B12: 21@ = 21@ XOR 1 //this will disable and enable with the same key
if
21@ == 1 // ENABLE IT
then
WHILE TRUE //here under while true will loop until 21@ = 0
wait 0
//do codes here
//...etc
but now for the big thing and the best use of while statement
the following script is new for you , the idea of it , is recovering health while you are holding key 1
so this is our script:
Code:
{$CLEO}
0000: NOP
:START //our label
wait 0
if // we need this to run when we are alive only
0184: actor $PLAYER_ACTOR health <> 0 // "<>" means not equal , 0 means actor health and 0 = dead , the normal full health is 100 in most of servers
jf [member=5120]Error[/member] // if actor is dead then jump at ERROR label
WHILE 0AB0: key_pressed 49 // key 1 // will be explained below don't worry
wait 0 //we add this to avoid crashing
0851: set_actor $PLAYER_ACTOR decrease_health_by -2 affect_armour 0 // decrease by -2 = increase by 2 , it is math , decrease means negative , and negative negative 2 means positive 2
0ACD: show_text_highpriority "Recovering 2H/ONHOLD" time 1500
END // to close WHILE statement
jump @START //jump to the label to loop again
:ERROR //our error label
wait 0
0ACD: show_text_highpriority "You're DEAD ...!" time 1500 // this will get printed when you die
jump @START // after display "You're DEAD" massage it will go to start label to loop again
so now "while" means while key 1 pressed run the script
we use while in our life , and it is same here
so while key 1 pressed = while we are holding key 1 run the script
this is what while means.
so while this condition is true do the following
and after every while we need wait 0
and we need the closer end just like then
this is while code:
Code:
WHILE "CONDITION IS TRUE"
wait 0
//do something here to get run while the condition is true
end
one thing more is if we want while not this condition is true
we use :
Code:
WHILE NOT 0184: actor $PLAYER_ACTOR health = 0 //this means actor health <> 0
wait 0
//do something here
end
and congratulations you just made a health generator hack
thanks for following my tutorials.
if i helped you please hit the thanks button and the little heart(rep.) under my name so you can make me more trusted for users so they can reach me easily.