User Tools

Site Tools



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

Link to this comparison view

harlowe:either [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(either: // ...Any//) -> //Any//**
 +Give this macro several values, separated by commas, and it will pick and return
 +one of them randomly.
 +=== Example usage: ===
 +''​%%A (either: "​slimy",​ "​goopy",​ "​slippery"​) puddle%%''​ will randomly be "A slimy puddle",​ "A goopy puddle"​
 +or "A slippery puddle"​.
 +=== Rationale: ===
 +There are plenty of occasions where you might want random elements in your story: a few random adjectives
 +or flavour text lines to give repeated play-throughs variety, for instance, or a few random links for a "​maze"​
 +area. For these cases, you'll probably want to simply select from a few possibilities. The (either:)
 +macro provides this functionality.
 +=== Details: ===
 +As with many macros, you can use the spread ''​%%...%%''​ operator to place all of the values in an [[harlowe:​array|array]] or [[harlowe:​dataset|dataset]]
 +into (either:), and pick them randomly. ''​%%(either:​ ...$array)%%'',​ for instance, will choose one possibility from
 +all of the array contents.
 +If you want to pick two or more values randomly, you may want to use the [[harlowe:​shuffled|(shuffled:​)]] macro, and extract a subarray
 +from its result.
 +=== See also: ===
 +[[harlowe:​random|(random:​)]],​ [[harlowe:​shuffled|(shuffled:​)]]
harlowe/either.txt ยท Last modified: 2017/10/09 20:39 (external edit)