User Tools

Site Tools


print

Differences

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

Link to this comparison view

Next revision
Previous revision
print [2013/12/15 02:49]
l created
print [2017/10/09 20:39] (current)
Line 1: Line 1:
 +<- [[function|About Functions]] --------- [[remember|Remembering Things With Variables]]->​
 +
 =====<<​print>>​===== =====<<​print>>​=====
  
 +The <<​print>>​ [[macro]] lets you print [[expression]]s,​ pure and simple.
 +
 +====Usage====
 +
 +>​%%<<​%%print //​expression//​%%>>​%%
 +
 +The expression'​s value is calculated and printed into the passage. If an error occurred while calculating,​ an error message will be printed instead.
 +
 +====Basic examples====
 +
 +<​code>​
 +"So, <<​print $playerName>>,​ we meet again!"​ booms the Wrestlemaster.
 +</​code>​
 +
 +<​code>​
 +Alas! <<​print visited()>>​ time(s) you've fallen in this damned pit!
 +</​code>​
 +
 +====Changing values while printing them====
 +
 +The <<​print>>​ macro has an extra feature: if you use "​to",​ "​+=",​ or other operators common to the [[<<​set>>​]] macro in the <<​print>>'​s expression, then it will change the variables //and// print the new values.
 +
 +For example:
 +<​code>​
 +After the transfusion,​ you have <<set $blood -= 7>><<​print $blood>>​ litres of blood left.
 +</​code>​
 +can be potentially rewritten as:
 +<​code>​
 +After the transfusion,​ you have <<​print $blood -= 7>> litres of blood left.
 +</​code>​
  
 ====Shorthand form==== ====Shorthand form====
Line 8: Line 40:
 This allows you to write Twine stories in a “template” style: This allows you to write Twine stories in a “template” style:
 <​code>​ <​code>​
-Your superior officer approaches. "<<​$name>>,​ you've done a fine job. No, a superlative job. <<​$species>>​ like you have no place on this cruel Earth, that rewards only greed and selfishness."​+Your superior officer approaches. "<<​$name>>,​ you've done a fine job. No, a 
 +superlative job. <<​$species>>​ like you have no place on this cruel Earth, 
 +that rewards only greed and selfishness."​
 </​code>​ </​code>​
  
 +**Note:** you can only perform this shorthand form using variables! You cannot, for instance, write <<​[[function|visited()]]>>​.
 +
 +<- [[function|About Functions]] --------- [[remember|Remembering Things With Variables]]->​
print.1387093755.txt.gz · Last modified: 2017/10/09 20:37 (external edit)