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
Next revision Both sides next revision
set [2013/12/17 20:52]
l
set [2013/12/24 01:39]
l [A note about <<set>> and links]
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''​ |
 +
 +====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)