Order of NPCs in room description

Dear all,
how can I affect the order in which NPCs are listed in the room description? I have no idea what the mechanics behind that order is, and moving them in an order or the reverse order of that yielded no effect.
(It’s two NPCs, and I want X listed first and Y second.)
Thanks!

I’m not experienced with Inform 6, but I know in I7 it depends on when objects/NPCs are defined in the text. Perhaps try switching the order the NPCs appear initially in your code?

If you’re talking about the list of objects that come at the end (“You can also see John, Sammy, a gun and a bullet here.”), they’re listed in the order they appear in the object tree. Whenever two items are in the same object (a room, a container etc), they have an internal order, and it’s generally the reverse order in which they were moved to their present location. If they are put there from the start using → or similar syntax, they appear in the order they were defined in the source.

If you compile in Debug mode, you can type “tree” to list all objects, showing them in this order.

If you give one object a describe property though, it will be described before all objects which don’t have describe.

And there’s initial, when_open, when_on etc, which also give precedence.

1 Like

Ahaha, one has an “Initial” definition. Okay, trying something…

If they always appear together, you can let one of them describe both in room descriptions.

Object -> Laurel "Laurel"
  with
    describe "Laurel & Hardy are here.",
    ...

Object -> Hardy "Hardy"
  with
    describe [; rtrue;],
    ...

Or you can just let Laurel drag Hardy into scope. Then Hardy will always tag along when you move Hardy, but the game will never try to describe him.

If they sometimes appear together, you can still do this:

Object -> Laurel "Laurel"
  with
    describe [;
        if (Hardy in location) "Laurel & Hardy are here.";
    ],
    ...

Object -> Hardy "Hardy"
  with
    describe [; 
        if (Laurel in location) rtrue;
    ],
    ...

This gets unwieldy with three or more objects, but it’s manageable for two.

2 Likes

I simply used Initial() for both NPCs and everything works as intended. Thanks for all the help!

2 Likes