5

I have the following code:

After going to room1:
    if button1 is switched on:
        say "You hear a loud noise in the distance!";

Unfortunately this prevents the room description from printing. If I add "continue the action;" at the end, then the output is "You hear a loud noise in the distance!" BEFORE the room description. I really want the room description first. If I add "try looking;" as the first line, it breaks the brief/verbose model. How do I code this to get the following output?

(verbose)

>e
Room1
This is a small room.
There is a letter here.
You hear a loud noise in the distance!

(brief, upon second visit to room)

>e
Room1
There is a letter here.
You hear a loud noise in the distance!
aschultz
  • 1,514
  • 3
  • 15
  • 24

2 Answers2

5

This is happening because "after" rules run before "report" rules, and the room description is printed by a report rule. So you have a few options to fix it:

  • Print the room description in your after rule. As you noticed, "try looking" breaks brief mode because it always responds as if the player typed LOOK, but there's another phrase you can use instead (it's mentioned in the Standard Rules section on looking):

    After going to room1:
        produce a room description with going spacing conventions;
        if button1 is switched on:
            say "You hear a loud noise in the distance!"
  • Print your message from a "report going" rule that runs after printing the room description:

    Last report going rule (this is the report loud noise in the distance rule):
        if the room gone to is room1 and button1 is switched on:
            say "You hear a loud noise in the distance!"
  • Print your message from an "every turn" rule, which runs after all the action rulebooks:

    Every turn when the player is in room1 and the player was not in room1:
        if button1 is switched on:
            say "You hear a loud noise in the distance!"
Jesse McGrew
  • 1,819
  • 17
  • 28
0

This happens because an "After" rule defaults to "success", meaning that anything that was going to happen later (including report rules and room descriptions) is cancelled. The solution is to simply add continue the action in your rule:

After going to room1:
    if button1 is switched on:
        say "You hear a loud noise in the distance!";
    continue the action;

This is somewhat similar to how "Instead" rules work - by default, the rule terminates further processing (but Instead rules default to failure rather than success).

celticminstrel
  • 1,501
  • 10
  • 18
  • That prints "You hear a loud noise in the distance" _before_ the new room description, right? The question is about how to print it after. – Jesse McGrew Feb 23 '16 at 06:14
  • Ah, you're right. Then this answer is pretty useless. I'll probably delete it, maybe make a new one if I think of some other solution. – celticminstrel Feb 23 '16 at 19:22