Stopping every turn rules from firing with Instead (or similar)

I feel like this is something that might be, in actuality, simple to do and I just haven’t found the right way. When a player’s action is stopped by an Instead or Check rule, the turn sequence rules continue and every turn rules still fire. Is there a way to prevent this from happening for specific rejected actions? I’ve tried all the “stop” phrases I know, from “stop the action” all the way up to “reject the player’s command”, but none of them have the intended effect. I have a vague idea of how to create a mechanism to stop the turn sequence with a variable, but if there’s already a built-in way to do it I’d rather use that.

1 Like

I think the easiest way to do this is to define a kind of action governing the actions you want to have bypass the turn sequence rules, then add a new rule to the beginning of the turn sequence rulebook that aborts the rest of it if the player’s action falls into the categories you’ve defined. Here’s a short, hopefully self-explanatory example I’ve used:

Examining something is acting fast. Looking is acting fast.  Taking inventory is acting fast.

The take visual actions out of world rule is listed before the every turn stage rule in the turn sequence rules.

This is the take visual actions out of world rule: if acting fast, rule succeeds.

(EDIT: You might need to do some tweaking depending on if you want to have every turn rules treated differently from scene change ones, and I think there might be some scoring stuff buried in the turn sequence rules too? But for most purposes I think this is basically OK).

2 Likes

That’s about what I’m currently thinking of doing (and I have similar code for other functions), but given that it’s truly hundreds of different actions and I’d like to be able to toggle whether the prevention triggers under different circumstances (like during certain scenes, or in the presence of people) I’m hoping for something a little more flexible.

1 Like

Hmm, yeah. Kinds of actions can have those qualifiers (examining in the courtyard is acting fast, examining in the presence of someone is acting fast, etc.) but if that’s still not granular enough you might just need to do the brute-force setting-and-resetting-a-global-variable approach, since I don’t think there’s anything built in that would otherwise accomplish this.

1 Like

I feared as much, but thought I’d check anyway. Thank you!

1 Like

I use the Variable Time Control extension for this kind of thing, which does use a global variable. You say ‘take no time’, and that stops the every turn rules running for a turn. I created a say phrase:

To say nt: take no time;

Having done this, I can drop the [nt] into any say phrase, and when that message is printed, it’s also going to act fast on that turn.

Obviously the pro of a global is you can set it anywhere, anyhow.

It may be helpful to combine both approaches (acting fast, and using a global).

You define a bunch of actions as acting fast. That covers them. Now say you’ve got one action someplace that doesn’t act fast in general, but you want it to in one circumstance. In that circumstance, just drop the [nt] in the message:

say "[nt]You don't think that will work.";

That’s super granular, and it’s on my mind every single time I create some text saying what an action did. No-time it or not?

In headache land, if you combine approaches, you must also remember to clear the global every turn, especially after an action that acted fast. Otherwise the global can get set, but then the acting fast skips the turn (instead of the global) and the next turn won’t ‘move’ either.

-Wade

3 Likes

Ah good stuff! I hadn’t considered Variable Time Control. That works beautifully.

2 Likes

Wade,
Variable Time Control already has this:

To say take/-- no-time: take no time.
To say take/-- no time: take no time.
1 Like

lab is a room.
abort-turn-sequence is initially false.

This is the abort turn sequence rule:
  if abort-turn-sequence is true begin;
    now abort-turn-sequence is false;
    rule succeeds;
  end if;

The abort turn sequence rule is listed before the every turn stage rule in the turn sequence rules.

Every turn: say "ET".

Instead of jumping, now abort-turn-sequence is true.

test me with "think / jump".

The versions of Variable Time Control I’ve seen don’t attempt to affect whether the Every Turn rules run; they just affect by how much time is incremented by replacing the Advance Time rule.

1 Like

Yes, but my brilliant move was reducing to two letters: [nt]

There are 715 occurrences of it in my WIP’s extensions alone. That’s more than 7000 fewer keys I’ve pressed!

-Wade

1 Like

I feel your pain. After implementing Zed’s solution into my pre-existing code (thank you, Zed!), I now have a full 1,045 instances—and I expect a good deal more before I’m done.

1 Like

Oh yeah. Well, I forgot that because I changed mine to affect Every Turn rules several years ago :slight_smile:

-Wade

1 Like

These are trivial tweaks, but on reflection, I like this better.

lab is a room.
abort-turn-sequence is initially false.

To abort turn sequence: now abort-turn-sequence is true.

This is the abort turn sequence rule:
    now abort-turn-sequence is false;
    rule succeeds;

The abort turn sequence rule is listed before the every turn stage rule in the turn sequence rules.

The abort turn sequence rule does nothing when abort-turn-sequence is false.

Every turn: say "ET".

Instead of jumping, abort turn sequence.

test me with "think / jump".
1 Like

Purely out of curiosity, and bc I find the code interesting and elegant, what’s the design philosophy behind the changes?

Aborting the turn sequence is doing something so it just felt better for it to be its own imperative phrase instead of a flag assignment. And I think there’s less chance of remembering incorrectly how you abort the turn sequence if it’s literally abort the turn sequence.

The other change is really trivial, and largely motivated by the if-block looking ugly. And for most people it’d look less ugly 'cause I’m about the only one who habitually uses begin / end. So :person_shrugging:

2 Likes