every turn

How do you effectively write an ever turn rule based on a truth state? like…

every turn if PlayInChair is true: say "hello".

also an every turn rule that adds to a variable based on a truth state…

example

every turn if PlayerInChair is true: x+=1

When conditions are made part of rule preambles, you have to use “when” or “while” instead of “if”:

Every turn while PlayInChair is true: say "hello".

For adding to a number variable, see ch. 8.12. “Increasing and decreasing”.

how about checking the equality of a variable? I can’t seem to find that.

Every turn while WaterRising = 5: end game in death.

will that do it?

Just “is” instead of “=” should do it.

hmm, end game in death isn’t working… also tried end game. Here’s a code snippet…

Every turn while WaterRising is 5: say " You fail to escape from the chair. The water slowly rises up over your face. You try to hold your breath, but it only lasts so long. A final scream of terror, and gasp for breath, brings about your horrific demise.";end game.

I think if you use the style of putting each part of a rule on a separate line, with indentations to indicate the “levels,” you need to do that throughout the entire rule. Thus:

Every turn while WaterRising is 5: say " You fail to escape from the chair. The water slowly rises up over your face. You try to hold your breath, but it only lasts so long. A final scream of terror, and gasp for breath, brings about your horrific demise."; end game in death.

(Note that the above example uses spaces to indent before the “end game” line; the spaces need to be replaced with a tab character to work properly.)

Robert Rothman

For some or no reason Inform never accepted ‘end game’; the correct syntax was ‘end the game’ with a mandatory definite article.

However, that phrase is now deprecated and will probably not be part of future Inform syntax. Use end the story finally saying "You have died!" (or “You have won!” or “You fail to escape from the chair. The water slowly rises up over your face. You try to hold your breath, but it only lasts so long. A final scream of terror, and gasp for breath, brings about your horrific demise.” or whatever you want Inform to print at that ending). See ch. 9.4. “When play ends”.

You probably don’t want “end the story finally”; that’s the equivalent to ending the game in victory. (This can affect the options for what the player can do after the game ends; many games prompt you for AMUSING things to do if the story has ended finally.) Just leave out “finally.”

Also, the last text Felix gives is too long. If you want to say something long, you should print it using a say phrase, and then end the story saying “You have drowned”. (I’m sure Felix didn’t mean it as a serious example, but one of the comp games actually did something like that, and it was confusing.)