When you use either a Naked Variable Reference or the (print:)
macro to output the value of a variable…
(set: $apples to 6)
<!-- Using a Naked Variable Reference.. -->
You have $apples Apples.
<!-- Using a Macro.. -->
You have (print: $apples) Apples.
…a copy of that variable’s current value is injected into the page’s HTML structure. And that is why any change you make to that variable’s value…
(set: $apples to 6)
Reference: You have $apples Apples.
Macro: You have (print: $apples) Apples.
(link-repeat: 'Buy an Apple')[
(set: $apples to it + 1)
]
…has no affect on the value being displayed on the page.
There are a number of different techniques you can use to update sections of the page, two of them being:
1: Using the (rerun:)
macro to re-execute the contents of a Named Hook.
(set: $apples to 6)
Reference: You have |apples>[$apples] Apples.
Macro: You have |apples>[(print: $apples)] Apples.
(link-repeat: 'Buy an Apple')[
(set: $apples to it + 1)
(rerun: ?apples)
]
2: Using the (replace:)
macro to replace the current content of a Named Hook.
(set: $apples to 6)
Reference: You have |apples>[$apples] Apples.
Macro: You have |apples>[(print: $apples)] Apples.
(link-repeat: 'Buy an Apple')[
(set: $apples to it + 1)
(replace: ?apples)[$apples]
]
note: I gave the Hooks the same Name as the variable they contained to make it clear what those Hooks represented, and to help me remember what they contained. But those Hooks could of been named anything else and would of still worked…
(set: $apples to 6)
Reference: You have |hiphop>[$apples] Apples.
Macro: You have |hiphop>[(print: $apples)] Apples.
(link-repeat: 'Buy an Apple')[
(set: $apples to it + 1)
(rerun: ?hiphop)
]
So if we applied the 1st technique to your own example…
(set: $pushes to 0)
(link-repeat: 'Push')[
(set: $pushes to it + 1)
(rerun: ?outcome)
]
|outcome>[{
(if: $pushes is 1)[
You have pushed the button one time. Nothing seems to happen yet.
]
(else-if: $pushes is 2)[
As you push the button a second time, you notice a mechanic sound behind the wall.
]
}]
note: The contents of the Named Hook is more complex this time, as it uses the (if:)
and (else-if:)
macros combined with a ‘counter’ variable to determine exactly what to display.