Here are some other approaches to this problem:
logic is initially 0. [or instead of '0', whatever start value you like]
Every turn:
if logic was not greater than 9 and logic is greater than 9:
say "[one of]Glad I worked that out![or]Worked it out again![stopping]";
Here logic is initially 0
is a shorter way of writing logic is a number that varies. logic is 0.
- the initially
tells inform that logic
may vary (always
here instead would signify a constant, unchanging value) and Inform deduces from the 0
that logic
is a number, as well as setting its starting value.
‘if logic was not greater than 9…’ means ‘if, at the start of this turn, the condition ‘logic is greater than 9’ was not true…’ (see Inform documentation §9.13. The past and perfect tenses). So the full phrase if logic was not greater than 9 and logic is greater than 9
will trigger only if logic
has changed during the course of this turn from 9 or less to greater than 9.
say "[one of]Glad I worked that out![or]Worked it out again![stopping]"
will cause the 1st text (before the [or]) to display the first occasion the say
phrase is triggered, and the 2nd text (after the [or]) on all subsequent occasions (see Inform documentation §5.7. Text with random alternatives- which also describes options for displaying text only the first occasion the say
phrase is triggered, and numerous other variations).
You could also take a look at §9.14. How many times? and §9.15. How many turns?: for example
if logic is greater than 9 for 1 turn
has exactly the same effect as
if logic was not greater than 9 and logic is greater than 9
meaning ‘if logic is greater than 9 now but wasn’t last turn’.
small print Note that the first example chosen in §9.15. How many turns? can initially lead to confusion as to how if ... for (x) turns
works, because of the use of the present perfect tense of the condition ‘if the floppy hat is worn’, i.e. ‘if the floppy hat has been worn’.
‘if the floppy hat is worn for 3 turns’ is equivalent to ‘if the floppy hat is worn for exactly three turns’ or '‘if the floppy hat is worn for the third turn’ and simply implies the floppy hat is worn now (1 turn) and last turn (2 turns) and the turn before (3 turns), but not the turn before that (4 turns).
‘if the floppy hat has been worn for 3 turns’ implies ‘if the floppy hat is worn now and was also worn for all of the previous 3 turns (and possibly more before that)’ and is equivalent to the (more intuitive) ‘if the floppy hat is worn for at least 4 turns’. (4 turns here being this turn and all of the previous 3 turns).
EDIT: more small print
The documentation is incorrect when it says that the following are equivalent:
if the floppy hat is worn for the third turn ...
if the floppy hat has been worn for only 3 turns ...
if the floppy hat has been worn for exactly three turns ...
‘if the floppy hat is worn for the third turn’ is equivalent to ‘if the floppy hat is worn for three turns’ but, as might be expected from the description above of ‘if the floppy hat has been worn for three turns’, the other two equivalent phrases should read as below:
if the floppy hat is worn for the third turn ...
if the floppy hat has been worn for only 2 turns ...
if the floppy hat has been worn for exactly two turns ...