Action Ordering?

I have a situation where I want a line of text to print only if the player entered this room from a particular other room. I found the Small Kindnesses example that sets former location, but I think I’m just having syntax problems. Even with Inform 7’s nice English error messages, they can be maddeningly unhelpful sometimes :stuck_out_tongue:

What I have is:

The Canyon Stretch3 is a room. The printed name is "Canyon". "The canyon continues stretching north-south. The towering walls provide some refreshing shade on the west side." Carry out going to Canyon Stretch3: if former location is the Canyon Bowl: say "The sun glints off something metallic on the east wall." South is the Canyon Stretch2. North is the Canyon Bowl.
The problem is that when I go south from the Canyon Bowl, it prints the extra line immediately after the command and before the room description. If I change “carry out” to “after” it doesn’t even print the room description at all. I’ve tried different condition structures and I can’t figure it out. How can I make it so that when you enter the Canyon Stretch3 from the Canyon Bowl it just adds that line after the room description?

P.S. - Originally the extra line was in the Canyon Stretch2, with the condition entering from Canyon Stretch3, but [former location] was always picking up the printed name, which is Canyon for both. Is there a way to make that see the room’s real name instead of the printed name? This is less of an issue than the first bit.

If the metallic glint is an item, you could put this in a “rule for writing a paragraph about…” or the initial appearance property.

You can do this (without needing Small Kindnesses!):

Last report going to Canyon Stretch3 from Canyon Bowl: say "The sun glints off something metallic on the east wall."

The description of the room gone into gets printed by a “report going” rule; if you look at the “How actions are processed” section of the documentation (12.2 in 6L02) you’ll see that the Report rulebook runs after the Carry Out and After rulebooks–and in fact if an After rule runs then the Report rules don’t run at all, unless we tell Inform to keep going by writing “continue the action”! This explains what happened with your After rule. If we just make this a Report rule it’ll still run first, because it’s more specific than the describe room gone into rule, but if we write “Last” that ensures that it goes at the end of the Report rulebook so it prints after the room description as you want.

It’s built into the Standard Rules that you can write “going to room1” and “going from room2” and Inform will understand, so if you’re just writing a rule for the going action you don’t need the former location. (Why this works is a bit esoteric; “the room gone to” and “the room gone from” are action variables for the going action, and the Standard Rules sets them as “matched as to” and “matched as from” respectively, which means that you can write “going to Canyon Stretch2” as basically an abbreviation for “going when the room gone to is Canyon Stretch2.”

As for your last question, if you write “[former location]” it’ll print the printed name of the former location–that’s what the printed name does–but this shouldn’t affect your internal comparisons in the source code. If you write “If the former location is Canyon Stretch3” it should work. If you write:

If "[former location]" is "Canyon Stretch3"

then it will fail because you’re doing a string comparison,* but it doesn’t look like you want to do a string comparison anyway. But I may have misunderstood that part of the question.

*Actually you may be doing a weird text substitution comparison that will always fail–I’m never quite sure what happens if you check text substitutions for equality instead of their “substituted form” from section 20.7 of the 6L02 documentation–but we don’t need to get into that, because that’s almost certainly not what you want to do.

You can do “first report…” “last report…” to make rules go first or last. You can also add “rule succeeds” to a report rule to make it not report anything else. You can also override every normal report rule with an “After…” rule.

For example, if I need to make sure that the player hears a clink when they pick up an object with something hidden underneath it.

Last report taking the book for the first time: say "Hey, was that a clink?"

or

After taking the book when the key is off-stage: say "You pull the book out of the bookcase. There is a faint clinking sound."; now the missing key is in the location.

This is exactly what I needed. Thanks! :slight_smile:

Just one thing to note: right now the glint will not appear if the player types “LOOK”, regardless of whence they came, so someone playing in “brief” or “superbrief” mode will never see it at all.

EDIT: Ignore this, see Matt’s comment below.

Actually it will (I just tested)–brief and superbrief mode will prevent the describe room gone into rule from firing, I think, but they won’t prevent other Report going rules from firing, so you should get the message about the glint when you go into Canyon Stretch3 from Canyon Bowl even in one of these modes.