User Tools

Site Tools


crpl:docs:if

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
crpl:docs:if [2014/10/01 15:02] – external edit 127.0.0.1crpl:docs:if [2016/10/09 20:42] (current) – Removed discussion tag GoodMorning
Line 1: Line 1:
-~~DISCUSSION~~ 
 <- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#flow_control|Flow Control]] <- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#flow_control|Flow Control]]
 =====  if  ===== =====  if  =====
Line 9: Line 8:
 === Description === === Description ===
 Evaluate the first element on the stack.  Evaluate the first element on the stack. 
-If True, then execute statements that follow, up to the endif statement.  +If True, then execute statements that follow, up to the endif or else statement.  
-If False, execution skips to the first statement following the endif statement. +If False, execution skips to the first statement following the endif or else statement. 
 Any nonzero value is consierered True, a value of zero is False. Any nonzero value is consierered True, a value of zero is False.
 === Examples === === Examples ===
Line 21: Line 20:
  endif  endif
 </code>  </code> 
 +<code> 
 +# Pick a random integer between 0(inclusive) and 100(exclusive). 
 +# If the random number is less than 95 emit 10 Creeper, 
 +# otherwise emit 100 Creeper. 
 +0 100 RandInt 95 lt if  
 + CurrentCoords 10 AddCreeper  
 + else  
 + CurrentCoords 100 AddCreeper  
 + endif 
 +</code>
crpl/docs/if.1412190170.txt.gz · Last modified: 2015/06/22 20:59 (external edit)