Here's one way of sending the game to a new section when an attribute reaches a certain value. The advantage of using a function is that it you don't have to force the player to click on a link to get to the desired section. (Although this example only has one option each time, you could add other options at every point.)
It does, however, require the author to specifically 'call' the function with a line of Javascript at any section where the attribute might have reached the conditional value.
I did try to include more 'auto' behaviour in the Master section, but so far I'm only having any luck with JS functions in the Master section. To my mind, this isn't really a disadvantage. It gives the author control over when / if to use the function.
@start start
[[]]:
/* This 'Master' section loads automatically on every section change. */
/* So the 'drinkCoffee' function is always 'available', and can be */
/* 'called' (with Javascript) from any point in the game. */
squiffy.drinkCoffee = function() {
if (squiffy.get("coffee") < 1) {
squiffy.story.go("End"); }
}
<!--
NOTE: The "drinkUp" section below is just an example of 'calling' on textual content
that's repeated several times in the game. Things like "@set" or Javascript
statements in the section will *not* be picked up and "embedded" or run in
the 'calling' section. But some things that refer to "in-line" text will -
such as the {if coffee> 1: . . . } part.
End Note -->
[[drinkUp]]:
You have {coffee} {if coffee> 1:gulps}{else:gulp} of coffee left.
[[drink some coffee]](Sec3)
[[start]]:
<!-- Note: "start" section initializes things, and does *not* -->
<!-- call on the Master section function. -->
@set coffee = 10
<b><u>Cafeteria</u></b>
Your break is 15 minutes.
You have about {coffee} gulps of coffee left in your cup.
[[drink some coffee]](Sec2)
[[Sec2]]:
/* We know that "coffee" is > 1 here. But there's */
/* no harm in calling the function anyway. */
squiffy.drinkCoffee();
@clear
<b><u>Cafeteria</u></b>
<br>
Someone stumbles and bangs into your table, almost knocking your coffee over.<br>
@dec coffee 3
{drinkUp}
[[Sec3]]:
squiffy.drinkCoffee();
@clear
<b><u>Cafeteria</u></b>
<br>
{if coffee> 4:<i>Break is almost over!</i>
You hurry to finish up, and spill some coffee down the front of your shirt.<br>}
@dec coffee 2
{drinkUp}
[[End]]:
@clear
<b><u>Office</u></b>
<br>
You down the last bit of your coffee, and head back to your office.