Thanks for all the helpful input. It appears that turns() works in the way that Chris described. The reason I was seeing the number of turns increase by 2 was that the SCORE command itself was taking one turn. So if I typed SCORE, SCORE, SCORE, the number of turns was being reported as 1, 2, 3, but if I typed SCORE, NORTH, SCORE, NORTH, SCORE, the number of turns was being reported as 1, 3, 5.
I currently have three "meta" commands, specifically ABOUT, HELP and SCORE. These are commands that are there purely to provide information. These should not increment the number of turns. System commands like SAVE, RESTORE, LOOK and INVENTORY should do the same thing. Unfortunately, as Chris pointed out, INVENTORY is buggy in this regard.
To work around this problem, I have done this:
integers {
score : integer "0";
turns : integer "0";
}
: increment "turns";
}
: match "score _" {
: decrement "turns";
: if (turns == 1) {
: print {(
"You have scored " + score + " points in " + turns + " turn."
)}
}
: else {
: print {(
"You have scored " + score + " points in " + turns + " turns."
)}
}
}
}
Now, when I type SCORE, NORTH, SCORE, NORTH, SCORE, the number of turns is reported as 0, 1, 2. Perfect. If I do the same thing to the system commands, they also work - even inventory! The only one that doesn't work properly is LOAD. This works fine normally, but increments the number of turns with my method.
Anyway, as an example, here's how I did inventory:
: match "inventory _" {
: decrement "turns";
: inventory;
}