User Tools

Site Tools


if

Differences

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

Link to this comparison view

if [2013/12/12 18:25]
l
if [2017/10/09 20:39]
Line 1: Line 1:
-The **<<​if>>​** [[macro]] is used to control what text the player sees when they visit a passage, or what macros are run when the [[passage]] loads. 
- 
-=====Usage===== 
- 
-The <<​if>>​ macro can be used in formats like these: 
- 
-><<​if //​condition//>>​ //Text// <<​endif>>​ 
- 
-><<​if //​condition//>>​ //Text// <<​else>>​ //Text// <<​endif>>​ 
- 
-><<​if //​condition//>>​ //Text// <<​else if //​condition//>>​ //Text// <<​else if //​condition//>>​ ... <<​endif>>​ 
- 
-//​condition//​ is a [[code]] expression that can evaluate to true or false. //Text// is any amount of passage text that you wish to display only if the condition is //true//. <<​endif>>​ is a macro tag indicating the end of the <<​if>>​ macro invocation. 
- 
-=====A note about line breaks===== 
- 
-When a passage containing an <<​if>>​ macro is displayed, the <<​if>>​ and <<​endif>>​ macro tags are removed from the text. But, the line on which the tags was placed will remain - thus, if it was by itself on a line, it will create a blank line. You can choose to fix this by ending the tags' lines with a [[syntax|backslash]]:​ 
- 
-<​code>​ 
-You leap over the sawblade with deft ease. 
-<<if $alive>>​\ 
-She laughs. "Still not dead? How callous of you to scorn Death'​s loving embrace!"​ 
-<<​endif>>​\ 
-</​code>​ 
- 
-You may, for larger <<​if>>​ constructions,​ use the <<​[[nobr]]>>​ macro instead: 
- 
-<​code>​ 
-You glare at the alien control panel. <<​nobr>>​ 
-<<if $red>>​ 
-The red button blinks <<if $earplugs>>​ and hisses<<​endif>>​ at you. 
-<<​endif>>​ 
-<<​endnobr>>​ 
-</​code>​ 
- 
-=====<<​else>>​===== 
- 
-<<​else>>​ is a macro that is used to indicate text that should be displayed if the condition is //false//. 
- 
-<​code>​ 
-The door to the left leads to the pantry. 
-<<if visited("​Pantry"​)>>​ 
-No way are you going back in there! 
-<<​else>>​ 
-Sounds like a good place to search... 
-<<​endif>>​ 
-</​code>​ 
- 
-The <<​else>>​ macro can itself contain another "if //​condition//",​ which causes the contents to only display if THAT condition is true: 
- 
-<​code>​ 
-<<if $health is 3>>\ 
-You're in tip-top condition - fighting fit and frankly fearsome. No human or god can lick you! 
-<<​else if $health is 2>>\ 
-DOOMED! You're DOOMED, puny player!! You've lost already! YOU CANNOT WIN!! MWAHAHAHAHA! 
-<<​endif>>​\ 
-</​code>​ 
- 
-You can insert as many <<​else if>>'​s as you want inside an <<​if>>​ / <<​endif>>​ pair. 
- 
-(Note: if you prefer, you can also write "else if" as "​elseif"​.) 
  
if.txt ยท Last modified: 2017/10/09 20:39 (external edit)