For ambiance, I have a character doing something every turn.
Every turn when the location is the checkout:
say "[one of]The cashier yawns loudly[or]The cashier loudly snaps her newspaper, then turns the page[or]The cashier stands up straight, then stretches her arms upward and outward[or]You can hardly believe how empty the pharmacy is. There isn't a single customer lined up at the cashier's counter[or]The cashier looks at you over the top of her newspaper, as if sizing you up[cycling].".
However, itâs inelegant when the player engages with the cashier, since there is already text characterizing the action.
What is the correct phrasing to skip this every turn rule when the player is performing specific actions? Or can I? Iâve tried lots of things and am simply not getting it right.
Thereâs probably a more elegant way to do this, but Iâd just create a truth state called like cashier-talking, set it to true in an after asking the cashier about or telling the cashier about rule (adding whatever other possible cashier actions there are â showing, giving), then having the every turn rule fire the ambient text if the truth state is false, or if itâs true set it to false for the next turn. Kludgy? Sure! Workable? Probably!
Iâve often thought it would be nice to have an action rulebook that happens after the Report stage finishes (i.e. after the action is truly complete) but before the Every Turn rules, for âaftereffectsâ of the action. It turns out this is actually quite difficult to make work in all situations (how should it interact with actions tried silently during the course of another action?), but you can often do the same thing with Every Turn rules.
Because as it happens, all rulebooks in Inform can, by default, care about the current action. You can say âevery turn of waitingâ the same way you say âbefore waitingâ or âinstead of waitingâ.
So:
Asking the cashier about is engaging in conversation.
Answering the cashier that is engaging in conversation.
[etc]
Every turn when not engaging in conversation:
Definition: an object (called o) is involved rather than uninvolved if o is the noun or o is the second noun.
After doing something when the location is the checkout and the cashier is uninvolved,
say "cashier does their thing.".
The trick here is that After rules come before Report rules (and block them, by default!) so this will come before (or instead of) the results of a successful action but after the results of an unsuccessful action, which Iâve always found mildly unintuitive. âAfterâ rules are a weird beast that I seldom use for that reason.
I had thought that wouldnât work 'cause I was half-remembering Supplied missing noun forgotten by end of turn (so scene change fails)? . Weâre actually warned in WI 12.10 to not use the current action phrase in an every turn rule. But depending on what the action had been in an every turn preamble is ok. Weird.
I was forgetting that âinvolvedâ is a built-in concept with the if [action] involves [object] phrase, so maybeâŚ
the previous action is an action that varies.
before doing anything, now the previous action is the current action.
every turn when the location is the checkout:
unless the previous action involves the cashier, say "whatever."
But this would fail to activate on, say, examining the cashier, so @Draconisâ specifying of the engaging in conversation kind of action would allow more control.
Great replies, everyone! Iâll be able to learn something from every option.
This one just occurred to me:
When in doubt, spread it out!
Every turn when the the location is the checkout (this is the checkout area rule):
if buying the action figure:
do nothing;
otherwise if talkingtoit the cashier:
do nothing;
otherwise:
say "[one of]The cashier yawns loudly[or]The cashier loudly snaps her newspaper, then turns the page[or]The cashier stands up straight, then stretches her arms upward and outward[or]You can hardly believe how empty the pharmacy is. There isn't a single customer lined up at the cashier's counter[or]The cashier looks at you over the top of her newspaper, as if sizing you up[cycling].".
I do it this way. Works well and is easy to manage.
Only if you end up in a situation where you have to set the âspoke-to-cashier-this-turnâ flag to true in so many different places in your code that itâs getting unruly would I think of going to a more complex system.