set

Differences

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

 set [2013/12/17 20:52]l set [2014/07/15 23:11]l [Setter operators] Both sides previous revision Previous revision 2014/07/15 23:11 l [Setter operators] 2013/12/24 01:39 l [A note about <> and links] 2013/12/18 04:07 l 2013/12/17 20:52 l 2013/12/17 20:04 l 2013/12/17 20:03 l created Next revision Previous revision 2014/07/15 23:11 l [Setter operators] 2013/12/24 01:39 l [A note about <> and links] 2013/12/18 04:07 l 2013/12/17 20:52 l 2013/12/17 20:04 l 2013/12/17 20:03 l created 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">>​ + <>​ + <>​ + ...can be changed to just this: + <​code><<​set \$pants = "​large";​ \$shoes = "​huge";​ \$spats = "​classy">>​ + ====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 %/ + <>​ + [[The lamp is red]] + <>​ + [[The lamp is blue]] + ​ + 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 <>​ 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"​]] +
set.txt ยท Last modified: 2017/10/09 20:39 (external edit)