Not reporting after a behavior action

Hiya!

I have a report rule for an action, which action is also a type of behavior that has an “after” rule. When I added the “after” rule, the “report” stage stopped working. Like so (details changed; I’m assuming this works the same way as my actual code):

Report taking the painting: say "You roll up the painting and put it in your bag."

Kissing Mr Carr is unmaidenly behavior. Doing something to the painting is unmaidenly behavior.

After unmaidenly behavior:
    say "How unmaidenly!"

“> TAKE PAINTING” would get me the “How unmaidenly!” text but not the report of its being taken. What do I need to fix?

Thanks!

1 Like

‘After’ rules assume that you are now done with the action and no longer need the ‘Report’ stage. Just add ‘continue the action’ at the end of your ‘after’ rule and any report rule with then run.

2 Likes

I see. So, now the report stage of the action is after the “after” stage. What’s the best/accepted way to flip this, so that the action completes and is reported first, and then the consequences of it happen next?

You could describe the action’s outcome in the after rule, so that the report stage is no longer needed.

Or you could write a scene that checks for the relevant game state (the player carrying the painting) and handles the consequences. An “every turn” rule could also do this.

Hm, okay, so it does sound like whatever I need to do to achieve what I’m going for is going to be kind of kludgey and weird, so I’m not missing something obvious. (The actual scenario is an NPC making snarky comments from a table of responses as the PC adds various things to a recipe.) Rather than describing the outcome in the after rule (since the after rule is written to cover several different actions under a single type) maybe I had better put the report and the NPC’s responses in the “carry out” rule?

I actually recently ran into a scenario very like this (PC needs to remain quiet during a ceremony, with NPC reacting in horror and restarting the ceremony if the player does anything labelled disruptive, which included conversation, singing, sneezing, etc.) For my purposes, it made sense to do this via an Every Turn rule, since regardless of what the disruption was, the NPC response and the game logic was the same. But if the NPC responses are customized to what exactly the PC is adding to the recipe, incorporating them into an item-specific rule probably makes sense (note that if you put the report and the NPC response in the Carry Out rule, you’ll still get the default Report rule firing afterwards, so Zarf’s suggestion using After rules is cleaner).

1 Like

Printing text in the carry out rule is generally discouraged. (I’m sure I’ve done it, but I try not to.)

You could certainly print both outputs in the report rule.

1 Like

I’ve adapted your scenario (Section 2) and included a short story (Section 1) which I think does exactly what you want. The rule names are not required, but it’s good practice when you’re trying to find or reorder rules:

Section 1 - Preliminaries

The library is a room.  Mr Carr is a man.  He is in the library.  The painting is in the library.

The block kissing rule is not listed in the check kissing rulebook.

Report kissing:
	say "The kissing bandit strikes again.".

Section 2 - Details

After taking the painting (this is the first after stuff rule):
	say "You roll up the painting and put it in your bag.";
	continue the action.

Kissing Mr Carr is unmaidenly behavior. Doing something to the painting is unmaidenly behavior.

After unmaidenly behavior (this is the second after stuff rule):
	say "How unmaidenly!".

The second after stuff rule (“after unmaidenly behavior”) takes place after the first after stuff rule (“after taking the painting”) because it is more specific. Fortunately this seems to be exactly what you want.

The “continue the action” statement allows the action to continue past the first after stuff rule.

Transcript:

library
You can see Mr Carr and a painting here.
>kiss Mr Carr
How unmaidenly!
>take painting
You roll up the painting and put it in your bag.
How unmaidenly!
>i
You are carrying:
  a painting
>

Furthermore, if you need more control over granularity of sequencing than << ‘After’ rules come before ‘Report’ rules and within each of these rulebooks ‘specific’ rules come before ‘general’ rules >>, you can explicitly control the order that rules fire within rulebooks with, for example:


Section 1 - Preliminaries

The library is a room.  Mr Carr is a man.  He is in the library.  The painting is in the library.

The block kissing rule is not listed in the check kissing rulebook.

Report kissing:
	say "The kissing bandit strikes again.".

Section 2 - Details

After taking the painting (this is the second after stuff rule):
	say "You roll up the painting and put it in your bag.".

Kissing Mr Carr is unmaidenly behavior. Doing something to the painting is unmaidenly behavior.

First after unmaidenly behavior (this is the first after stuff rule):
	say "How unmaidenly!";
	continue the action.

This tweak (stating ‘First after’ instead of just ‘After’) overrides the ‘specific’ before ‘general’ sequencing and ensures that the rule for reporting unmaidenly behaviour precedes that for taking the painting (note this also requires a reversal to which of these continues/terminates (by implication) the action).


**Library**
You can see Mr Carr and a painting here.

>take painting
How unmaidenly!

You roll up the painting and put it in your bag.

>
3 Likes

Although conceptually, since the response to taking the painting in particular is simply a report to replace the bog-standard report of ‘Taken.’ for a taking action that succeeds, it would be appropriate to have this one at least as a ‘Report’ rule rather than an ‘After’ rule:

Report taking the painting:
	say "You roll up the painting and put it in your bag." instead.

Note that, in contrast to ‘After’ rules, ‘Report’ rules by default continue the action, so ‘instead’ (or alternatively ‘stop the action’) is required if you don’t want the generic ‘Taken.’ response to fire subsequent to your bespoke report.

Again, in this example, without the need to state it explicitly, this ‘specific’ rule fires before the ‘general’ ‘Report taking’ rule.

1 Like

Thank you all! I will revisit this advice if I end up needing it - for now, the game is small and circumscribed enough that I just duplicated the “consult the table, print the NPC’s response” in the report stage for two different actions, but I appreciate the help.

Report rules are intended for general default responses to actions.
After rules are intended for specific responses that override the default response.

As such using an After rule here is the most sensible choice.

But yes, you can use either; the conventions are just conventions and don’t have to be strictly followed.

2 Likes

I guess there’s a case for that, but also a counter-argument (more usually applied to the ‘Instead’ rulebook) not to clutter up the rulebooks applicable to multiple actions (‘Before’, ‘Instead’, ‘After’) with too many rules applicable only to one specific action.

One practical rather than philosophical argument made for this is that during play these ‘multiple-action-applicable’ rulebooks must be fully searched through for applicable conditions on each and every turn, which may have performance implications for large projects running on slow platforms.

As you say, there is however nothing hard and fast to these conventions and personal preference and a willingness to deviate from convention when circumstances dictate are probably both equally important… :slight_smile:

But one-off exceptions are precisely what Before, Instead, and After are intended for. The default specificity rule-sorting behavior ensures that NI only considers the most relevant rules, and in the case of Instead and After, if it finds any rule that applies (and doesn’t end with continue the action.), it immediately short-circuits the rules tracing after that specific rule is fired.

Most importantly, if you’re writing a game big enough to have many dozens of these rules, the compiler will refactor the code to lump them all into a single rule to improve efficiency. https://midiguru.wordpress.com/2010/07/21/instead-of-instead/

Honestly, if you’re not targeting a minimal device and writing a huge game, it’s not worth worrying about. The average computer today is much more powerful than a decade ago when that was written, and as noted it wasn’t really true even then.

The usual coding recommendation is write first, optimize later, if necessary. You can’t know what portion will be a bottleneck until your codebase has grown beyond a certain size, anyway. Breaking with the conventions of the existing rulebook system and having to mark each of your rules as ending in success, or failure, or make no decision, to prevent obscure bugs by interacting with other rulebooks, not to mention other peoples’ extensions or code from co-authors, is just making more work for yourself to no perceivable benefit in almost every case.

1 Like

OK, I concede :slight_smile:

The easiest kludge if you want the text from both AFTER and REPORT: include the report text in the after message like so:

After taking the hard to obtain boat rope:
     say "Finally, you have the rope. Jeesh, that was difficult.[paragraph break]Taken."
2 Likes

Well, you can… and that’s mostly useful if you want to change the order (say something specific after the regular message).

But if you want to say something extra before the standard message then it’s better to just write an extra Report rule (or an After rule that includes continue the action); either way that’ll run before the standard rule, and means you don’t have to duplicate its text.

Perhaps the most elegant way to change the order of standard/exceptional response for occasional use is to use a ‘Last report’ rule, which will run in the standard report rulebook after the usual response has run:

Last report taking the painting:
    say "You thieving hound!".

If there is going to be a lot of post-reporting commentary in your game, the most elegant solution is perhaps to insert a new rulebook that runs after the ‘Report’ rulebook:

The Comment on rules are an action based rulebook.
This is the commentary stage rule: follow the Comment on rules.
The commentary stage rule is listed after the report stage rule in the specific action-processing rulebook.

Comment on someone displaying unmaidenly behavior in the presence of the player (this is the comment on someone else being unmaidenly rule):
	say "[Our] sensibilities are outraged!".
	
Comment on an actor taking the painting (this is the comment on anyone taking the painting rule):
	say "Even to touch this old master is a sacrilege!".
2 Likes

Or, more complicated but possibly more generically ‘correct’ (in case the standard response gets altered at some point)

After taking the hard to obtain boat rope:
     say "Finally, you have the rope. Jeesh, that was difficult.[paragraph break][text of standard report taking rule response (A)]"
1 Like

Man, we really are approaching dozens of comments on the topic of “why can’t Inform make actions happen FIRST and their consequences happen NEXT,” aren’t we? :stuck_out_tongue:

(Having the same inverted report issue with a different part of the game now! Wooo!)

Edit: It occurs to me (I haven’t tried it yet, but will tomorrow) that although my new issue isn’t solvable the way the previous one was (because the previous one was only NPC commentary so it could really go in a report rule even if that required some duplication; this one involves moving things around), I might be able to break an action into component parts that complete in order. Eg.

Carry out stabbing:
    try jabbing;
    try the NPC riposting;
1 Like