~~NOTOC~~
<= [[4rpl:start| Index]] \\
<= [[4rpl:start#Flow Control]]
====== repeat ======
Repeat
===== Description =====
Part of the "while: loop construct. Pops an item from the stack. If true, execute the following statements. If false, jump to the statement following ‘endwhile’.
===== Examples =====
5 ->y
while
<-y gt(0) #is y greater than zero?
repeat #repeat this section of code
trace(<-y)
<-y sub(1) ->y #subtract 1 from y so we don't end in infinite loop
endwhile
# UNIT SCRIPT
# This script increases the max health of the unit over time.
# The script won't be stuck in the loop since it's limited by the unit's
# Health regen rate or "GetUnitHealRate(self)".
while(GetUnitHealth(self) GetUnitMaxHealth(self) eq) #If unit's current health is equal to it's max health...
repeat #...repeat this section of code.
SetUnitMaxHealth(self GetUnitMaxHealth 0.5 add) #Add 0.5 points of max health to the unit
SetUnitDebugText(self Concat("Max Health: " GetUnitMaxHealth(self)) #Visual aid for you to know.
endwhile
<=[[4rpl:start| Index]]