User Tools

Site Tools



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

Link to this comparison view

harlowe:display [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(display: //​[[harlowe:​String|string]]//​) -> [[harlowe:​Command|Command]]**
 +This [[harlowe:​command|command]] writes out the contents of the passage with the given [[harlowe:​string|string]] name.
 +If a passage of that name does not exist, this produces an error.
 +=== Example usage: ===
 +''​%%(display:​ "​Cellar"​)%%''​ prints the contents of the passage named "​Cellar"​.
 +=== Rationale: ===
 +Suppose you have a section of code or source that you need to include in several different
 +passages. It could be a status display, or a few lines of descriptive text. Instead of
 +manually copy-pasting it into each passage, consider placing it all by itself in another passage,
 +and using (display:) to place it in every passage. This gives you a lot of flexibility:​ you can,
 +for instance, change the code throughout the story by just editing the displayed passage.
 +=== Details: ===
 +Text-targeting macros (such as [[harlowe:​replace|(replace:​)]]) inside the
 +displayed passage will affect the text and hooks in the outer passage
 +that occur earlier than the (display:) command. For instance,
 +if passage A contains ''​%%(replace:"​Prince"​)[Frog]%%'',​ then another passage
 +containing ''​%%Princes(display:'​A'​)%%''​ will result in the text ''​%%Frogs%%''​.
 +Like all commands, this can be set into a variable. It's not particularly
 +useful in that state, but you can use that variable in place of that command,
 +such as writing ''​%%$var%%''​ in place of ''​%%(display:​ "​Yggdrasil"​)%%''​.
harlowe/display.txt ยท Last modified: 2017/10/09 20:39 (external edit)