User Tools

Site Tools


twine1:either

Differences

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

Link to this comparison view

twine1:either [2017/10/09 20:39] (current)
Line 1: Line 1:
 +====either(value,​ value, ...)====
  
 +Give the either() function several string or number values, separated by commas, and it will pick one of them randomly. This allows a good degree of randomness to be inserted into the story, while still being fairly readable.
 +
 +You can use either() with [[<<​print>>​]] to print a random message or phrase...
 +<​code>​
 +"I sentence you to be buried alive in <<​print either("​rhinoceros","​buffalo","​triceratops"​)>>​
 +<<​print either("​vomit",​ "​sweat",​ "​snot"​)>>​!"​ the JudgeBot crackles noisily.
 +</​code>​
 +...or with [[<<​display>>​]] to display one of a set of passages.
 +
 +You can also use either() with [[<<​set>>​]] to set variables to random values:
 +
 +<​code>​
 +<<set $playerMoxie to either(2, 4, 6)>>
 +<<set $playerAttire to either("​green",​ "​black",​ "​rainbow"​)>>​
 +You have <<​print $playerMoxie>>​ moxie points, and <<​print $playerAttire>>​ armour.
 +</​code>​
 +
 +And, in addition to macros, you can use either() with the [[link]] syntax to make a link that goes to a random passage:
 +
 +<​code>​
 +You plunge into the [[glowing vortex|either("​12000 BC","​The Future","​2AM Yesterday"​)]].
 +</​code>​
twine1/either.txt ยท Last modified: 2017/10/09 20:39 (external edit)