User Tools

Site Tools


set

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
set [2013/12/17 20:04]
l
set [2014/07/15 23:11]
l [Setter operators]
Line 8: Line 8:
 (Joe Dever, //Flight from the Dark//) (Joe Dever, //Flight from the Dark//)
  
-You can keep track of the number of meals that the protagonist carries with the ''<<​[[set]]>>'' ​macro, like so:+You can keep track of the number of meals that the protagonist carries with the [[<<set>>]] macro, like so:
  
 <​code>​ <​code>​
Line 38: Line 38:
 | *=          | Multiplies the variable on the left by the number on the right. ''​$var *= 2''​ is shorthand for ''​$var to $var * 2'' ​        | ''​$shields *= 2''​ | | *=          | Multiplies the variable on the left by the number on the right. ''​$var *= 2''​ is shorthand for ''​$var to $var * 2'' ​        | ''​$shields *= 2''​ |
 | /=          | Divides the variable on the left by the number on the right. ''​$var /= 2''​ is shorthand for ''​$var to $var / 2'' ​        | ''​$coins /= 2''​ | | /=          | Divides the variable on the left by the number on the right. ''​$var /= 2''​ is shorthand for ''​$var to $var / 2'' ​        | ''​$coins /= 2''​ |
 +
 +====Multiple operations in one <<​set>>​ ====
 +
 +When you have multiple <<​set>>​ macro tags next to one another, you can replace them with a shorthand that uses only one <<​set>>​. Simply take the operations in each instance, and join them together using either commas or semicolons.
 +For instance, these three macro tags:
 +<​code><<​set $pants = "​large">>​
 +<<set $shoes = "​huge">>​
 +<<set $spats = "​classy">></​code>​
 +...can be changed to just this:
 +<​code><<​set $pants = "​large";​ $shoes = "​huge";​ $spats = "​classy">></​code>​
 +====A note about <<​set>>​ and links====
 +
 +It is easy to assume that the placement of links in a passage has some bearing on what the game's variable state will be once you click it:
 +<​code>​
 +/% The following code is ineffectual %/
 +<<set $lamp to "​red">>​
 +[[The lamp is red]]
 +<<set $lamp to "​blue">>​
 +[[The lamp is blue]]
 +</​code>​
 +But this is erroneous! All of these [[<<​set>>​]] macros are run as soon as the passage is displayed, in order. Clicking the "The lamp is red" link won't cause the <<set $lamp to "​blue">>​ tag to not have happened.
 +
 +To achieve the desired effect in the above passage, you should use [[link|setter links]]:
 +<​code>​
 +[[The lamp is red][$lamp = "​red"​]]
 +[[The lamp is blue][$lamp = "​blue"​]]
 +</​code>​
set.txt ยท Last modified: 2017/10/09 20:39 (external edit)