User Tools

Site Tools


4rpl:commands:while

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
4rpl:commands:while [2021/12/23 14:29] Karsten754rpl:commands:while [2024/06/05 22:23] – [Examples] LiteralNoob
Line 14: Line 14:
 ===== Examples ===== ===== Examples =====
 <code 4rpl> <code 4rpl>
 +# CONSOLE SCRIPT
 5 ->y 5 ->y
 while   <-y gt(0)    #is y greater than zero? while   <-y gt(0)    #is y greater than zero?
Line 19: Line 20:
     trace(<-y)     trace(<-y)
     <-y sub(1) ->  #subtract 1 from y so we don't end in infinite loop     <-y sub(1) ->  #subtract 1 from y so we don't end in infinite loop
 +endwhile
 +</code>
 +<code 4rpl>
 +# 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 endwhile
 </code> </code>
 <=[[4rpl:start| Index]] <=[[4rpl:start| Index]]
  
4rpl/commands/while.txt · Last modified: 2024/06/11 12:16 by Kalli