Every turn timing

Ok, of all the questions I’ve asked, I’ve spent more brain time on the following sync issues over the weeks than on anything else, and I haven’t been able to hack or fully solve them. So I’m here to grovel for help.

Say I have it so a character shows their health in their initial appearance:

‘Undamaged guy is here’, then ‘Hurt guy is here,’ (after 1 hp damage) for instance…

… and this character heals 1 hp per turn, thanks to an every turn rule.

If I punch a guy into the next room so he’s down a hp and follow him, his printed description as I enter says ‘Hurt guy is here’… but then before the prompt appears, but after it’s said that he’s hurt, he heals a hp and is no longer hurt.

If I type ‘look’ now (which is a take-no-time command in this game), it will say ‘he looks to be in perfect health’, right after having said ‘hurt guy is here’, so that’s the most obvious problem. His description is permanently out of sync with his health.

Many other problems grow from this sync issue. All workarounds I’ve tried interact with each other and create more problems in one place or another at different times. Some I’ve tried include:

  • Having his descriptions correspond to his health on a delay of 1. (IE when his hp are really x, you see the message for when they are x+1)

  • I’ve tried moving the moment of healing, and/or the moment of updating his description to some other part of the turn. This is hard. I tried to cram them into the moment of writing a paragraph about the guy, but of course, not all time-consuming actions print a paragraph about him. Then you also have to stop the healing happening if you repeatedly ‘look’ at the guy, or when other actions cause extra ‘looks’.

Is there some simple approach to this issue that I’ve overlooked or am unaware of? I guess what I want ideally is the equivalent of an every turn rule that goes off before all the descriptions are printed (or at turn start), not after (at turn end). But I don’t know if such a thing exists.

The way you’re describing it, it sounds like it should work:

  1. punch NPC ( -1 hp) during carry out punching (or whatever) rules
  2. NPC moved into next room (also presumably during carry out)
  3. action finished and every turn rules fire (NPC regains 1 HP) (turn ends)
  4. Player types “GO NORTH” or whatever and enters a room with the NPC at full health
  5. automatic “Look” action fires, with description accurately reflecting NPC HP

Now if by “follow” you mean the game automatically moves the player into the second room during the act of punching (i.e. before the every turn rules fire and the turn ends), there’s your problem. When the player is moved, a “look” is automatically generated and since it’s still part of the last turn, the HP hasn’t been updated yet. The solution will depend on the exact specifics of when in the turn sequence these events are taking place.

Does the problem pretty much go away if you report the healing to the player at the moment it happens?


EDITED to arrange the faux transcript correctly.

For completeness, the way you would do that is:[code]The before each turn rulebook is a rulebook.
This is the before each turn stage rule:
follow the before each turn rulebook.
The before each turn stage rule is listed before the parse command rule in the turn sequence rulebook.

There is a room.
Before each turn:
say “(Healing here.)”[/code]

That’s an elegant way to do it. More commonly, stuff that happens at the beginning of a turn is done with an “After reading a command” rule.

I tend to do things like Erik does, though - I don’t worry so much about when the rule fires, as long as it gives you a message that something has changed.

You should know about the Rules Chart. It’s a useful PDF giving a detailed map of all the major rulebooks and when they run. It’s linked at the bottom of this page:


Thanks for all the approaches folks.

I think EmacsUser’s approach will address all my problems in this case. There were lots of offshoot issues I didn’t go into. After reading that bit of code, I dug into Standard Rules again and got a stronger sense of the every turn rules.

Also thanks for the link to the chart file.

Just an update on this topic. I tried adding a new every turn type rulebook before the players command is parsed, ala EmacsUser, but that doesn’t actually get things to happen before the room description is printed.

You can go nuts if you aren’t sure when the time sensitive stuff is happening, so I nailed down the moment of healing to one spot (every turn rules) and let the description of the person be updated whenever a writing a paragraph about’ him rule went off.

Then, whenever circumstances would lead to a paragraph being written which would prove inaccurate by the time the player got to enter another command, I got the game to set a flag at that moment which would trigger a one-off fix in the ‘writing the paragraph about’ rule.

I eventually got this combination of stuff working.

Oh I see—you want the healing to happen before the report rulebook for some actions (like going), but after for others (like looking). Sorry for my misunderstanding. Perhaps you want something along the lines of [code]There is a room. South is another room.
Bob is a man in another room. Bob has a number called hp. The hp of Bob is four. The printed name of Bob is “Bob ([the hp of Bob] hp)”.

Looking is taking no time.

This is the healing rule:
say “(Healing here.)”;
increment the hp of Bob.
Carry out going:
follow the healing rule.
Every turn:
unless the current action is going or the current action is taking no time:
follow the healing rule.

Test me with “s / l / jump / l”.[/code]Or perhaps you just want to stick with what you have.