User Tools

Site Tools


display

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
display [2013/12/25 03:29]
l [Shorthand form]
display [2017/10/10 00:39] (current)
Line 1: Line 1:
 +<- [[code|Why Use Code]] --------- [[expression|About Expressions]]->​
 +
 ===== <<​display>>​ ===== ===== <<​display>>​ =====
  
Line 8: Line 10:
  
 Shorthand form (see below): Shorthand form (see below):
->​%%<<​%%//​string//​ //[value ...]//​%%>>​%%+>​%%<<​%%//​[[expression|string]]// //[value ...]//​%%>>​%%
  
 ====Motivating example==== ====Motivating example====
-Suppose you have a block of text or code which appears identically in multiple passages. It can be a pain to have to keep track of each instance in which it was used, especially when fixing spelling or link names. <​display>>​ provides you with an elegant means of reusing this text: simply place it in another passage, and then use <<​display>>​ in each of the places it is used.+Suppose you have a block of text or code which appears identically in multiple passages. It can be a pain to have to keep track of each instance in which it was used, especially when fixing spelling or link names. ​<<​display>>​ provides you with an elegant means of reusing this text: simply place it in another passage, and then use <<​display>>​ in each of the places it is used.
  
-Consider this source code, which paraphrases one of the first scenes of //The Hitchhiker'​s Guide to the Galaxy://+Consider this example:
  
-<​code>​ +{{ :display2.png |}}
-:: The world is ending +
-The world is about to end -- something about construction of a bypass? -- and +
-you only have time to buy one thing at the pub. +
-* [[Buy another beer]] +
-* [[Buy a sandwich]]+
  
-:: Buy another beer +In all of the above passages, the entire text of the passage "window" will be displayed after the text, thus saving ​the need to reproduce ​it exactly ​in each passage.
-Ford had said something about muscle relaxant. +
-You decide to take him at his word. +
- +
-<<​display '​Vogons begin'>>​ +
- +
-:: Buy a sandwich +
-For some odd reason you've been craving a cheese sandwich ​all day, and it looks +
-like you won't have a chance to have one anytime soon. +
- +
-<<​display '​Vogons begin'>>​ +
- +
-:: Vogons begin +
-You hear a great rumbling from outside, and rush outside to see what's going on... +
-<<set $vogons to true>>​ +
-</​code>​ +
- +
-In both of those passages, the entire text of the passage "Vogons begin" will be displayed after the text. Since its text contains ​the macro <<set $vogons ​to true>>,​ then it will indeed be set in both of those passages.+
  
 ====A note about tags==== ====A note about tags====
Line 66: Line 46:
 This shorthand form allows you to write Twine stories in a "​template"​ style: This shorthand form allows you to write Twine stories in a "​template"​ style:
  
-<​code>​ +{{ :display.png |}}
-:: Battle start +
-With a resounding cry of "<<​battlecry>>",​ your <<​minions>>​ rush into battle! +
- +
-:: battlecry [nobr] +
-<<if $morale > 2>> +
-Victory is ours! +
-<<​else>>​ +
-Help us! +
-<<​endif>>​ +
- +
-:: minions [nobr] +
-<<if $species is "​globbo">>​ +
-globlings +
-<<​else if $species is "​varavar">>​ +
-vara-thralls +
-<<​endif>>​ +
-</​code>​+
  
 As you can see, the "​battlecry"​ and "​minions"​ passages can be displayed in place of those <<​[[if]]>>​ statements throughout the story, with little hindrance to the readability of the passage text. As you can see, the "​battlecry"​ and "​minions"​ passages can be displayed in place of those <<​[[if]]>>​ statements throughout the story, with little hindrance to the readability of the passage text.
Line 89: Line 52:
 (The two passages use the [[tag|nobr tag]] to eliminate line-breaks.) (The two passages use the [[tag|nobr tag]] to eliminate line-breaks.)
  
 +====Passing data to displayed passages====
 +
 +See the documentation for the [[function#​parameter_number|parameter()]] function.
 ====Displaying a script passage==== ====Displaying a script passage====
  
Line 102: Line 68:
  
 When displayed, the passage will keep attempting to display itself over and over until the reader force quits his Web browser. This doesn'​t do permanent damage, but it will not endear yourself to your reader. When displayed, the passage will keep attempting to display itself over and over until the reader force quits his Web browser. This doesn'​t do permanent damage, but it will not endear yourself to your reader.
 +
 +<- [[code|Why Use Code]] --------- [[expression|About Expressions]]->​
display.1387942144.txt.gz · Last modified: 2017/10/10 00:37 (external edit)