User Tools

Site Tools


set

Differences

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

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
set [2013/12/17 20:03]
l created
set [2013/12/24 01:39]
l [A note about <<set>> and links]
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 28: Line 28:
  
 ====Setter operators ==== ====Setter operators ====
-The ''​to''​ and ''​-=''​ are special operators called ​**setter ​operator** - while [[expression]]s may contain comparison operators like ''​+''​ or ''​not'',​ setter operators are commands to modify the values of variables. The ''​-=''​ operator lowers the variable on the left by the value on the right. There is also a ''​+=''​ operator that does the opposite. +The ''​to''​ and ''​-=''​ are special operators called **setter ​operators** - while [[expression]]s may contain comparison operators like ''​+''​ or ''​not'',​ setter operators are commands to modify the values of variables. The ''​-=''​ operator lowers the variable on the left by the value on the right. There is also a ''​+=''​ operator that does the opposite.
- +
-====Setter operators====+
  
 The most useful setter operators are as follows: The most useful setter operators are as follows:
Line 40: 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''​ |
 +
 +====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)