# extracting the repetition count of an action?

Is there some way to obtain the repetition count of an action within the processing of that action? Something like this:

``````Instead of frobbing:
If the repetition count of the current action is 1:
say "1";
else if the repetition count of the current action is 2:
say "2";
else:
say ">2";``````

It doesn’t appear to me that this is possible from what appears to be the relevant part of the docs (section 12.20). The “action name part of” and “noun part of” and “second noun part of” etc are available, but not apparently something like “the repetition count of”.

Is it thus the case that one must use this more cumbersome sort of syntax?

``````Instead of frobbing for the first time:
say "1";

Instead of frobbing for the second time:
say "2";

Instead of frobbing for more than the second time:
say ">2";``````

This might seem to be a trivial difference, but it becomes more important when tracking more repetitions (say, the first ten) and what happens is more complex. TIA.

You can abbreviate after the first one.

``Instead of doing it for the second time...``

Remember: if you intervene with an Instead rule which interrupts action processing, this usually doesn’t count as a success, thus not incrementing the “count” of how often the action happened.
If you want to change what is said, you could also:

say “[one of]One[or]Two[or]Three[or]Four[or]More than four times[stopping]”

See the chapter on text with random alternatives!

```N is initially 0. [this defines N as a number that varies. You could give it a better name, like Frobbed_Count] Instead of Frobbing: Increment N; Say "[N]".```

Thanks for the suggestions. As I feared: there is no built-in mechanism; one must roll one’s own solution or use the wordier syntax.

The external counter mechanism requires an additional step to reset the count to zero when any other action interrupts the repetition. This should be doable with a stored action variable to save the current action so the counter mechanism can detect the action change – and it would have to register and update all such counters when there’s more than one.

All this veers near to the Verge of Hackery, so it’s too bad that we can’t access this internally-maintained variable directly. I think the officially-sanctioned approach is looking safest.

Building it yourself is, by definition, no hackier than relying on the built-in hacks.

I didn’t realize that by “repetition” you meant that the player repeats this action without doing something else in between. Couldn’t this be done by something like this:

``Instead of frobbing for [exactly/at least] three turns...``

But this still doesn’t solve your problem that the number of turns usually isn’t stored in an action variable and you have to do that by yourself.

And again, with this syntax you can abbreviate to “instead of doing it for four turns” or whatever.

I don’t think you understand what he wants to do. Basically, he wants to have it spit out the number of turns that the player has been consecutively frobbing, and he doesn’t want to write out 100 or more of those rules.

If you’re only interested in consecutive streaks of the same action, then you only need one counter – reset the counter whenever the action changes, and look at the current action to see what action is being done consecutively. You can’t have more than one action at a time being done in consecutive streaks, so there’s no need to keep track of more than one number.

Did he say that? I thought the code sample was meant to be nothing more than an example: if he just wanted to print that number it would be relatively easy.

```The counter is a number variable. Instead of frobbing for one turn: now the counter is one. Instead of frobbing for at least two turns: increment the counter; say "[counter]".```

What’s harder is doing this for several different actions, with different counters, or letting multiple actions share a counter.

Turns out that the instead rules don’t interrupt the internal count, which advances anyway (at least with 6L02). However, the count is cumulative and does not reset when there is an intervening action – which makes sense but is a different behavior than I simplemindedly presumed: a “total number of times the action is called in the game” count, not a “number of times the action is called in a row without interruption by a different action”:

``````The Lab is a room.

A baz is a thing in the Lab.

Instead of examining the baz for the first time:
say "Baz take1[paragraph break]";

Instead of examining the baz for the second time:
say "Baz take2[paragraph break]";

Instead of examining the baz for more than the second time:
say "Baz is getting boring[paragraph break]".

Frobbing is an action applying to one thing. Understand "frob [something]" as frobbing.

say "frob that baz![paragraph break]".

Test me with "examine baz / again / frob baz / again / examine baz / again".``````

The “examine count” rises to two after the second “examine” call and does not revert to zero despite the “frob” call. Thus if you want to generate different responses each time the PC repeats an action but have that series start over when the PC comes back at a later time and performs the action again, then a custom counter mechanism is necessary. FWIW.

Uuuh, I was nearly sure the documentation says that this is not the case, but I’m using 6G60 most of the time. Could someone make this clear, please?

Yes, this is what I said. You have to use “for two turns” not “for the second time” to count the same action on successive turns!

Aha: you are so right; thanks for underscoring the difference between “n turns” and “n times”!

``````The Lab is a room. A baz is a thing in the Lab.

Instead of examining the baz for one turn:
say "Baz take1[paragraph break]";

Instead of examining the baz for two turns:
say "Baz take2[paragraph break]";

Instead of examining the baz for more than two turns:
say "Baz is getting boring[paragraph break]".

Frobbing is an action applying to one thing. Understand "frob [something]" as frobbing.