Newbie Question: Locale Priorities

One of my favourite activities when writing IF is obsessing about the order in which objects are listed in the room description. After defeating the Inform docs in a pitched search-fu battle, I understand that I need to use a property (or is it something else?) called the locale priority.

Naively adding “The locale priority of some guy is 10.” to my code fails, so I gather I have to do something extra - although it’s tough to tell what, because the documentation mixes it up with an example of how to “check the [priority?] table for debugging purposes”, which I have no interest in.

I think the code I need is something like this:

After choosing notable locale objects: set the locale priority of the early bird to 1; [list before everything else -- this would work with any number lower than 5 and higher than 0] set the locale priority of the unseen object to 0; [don't list at all] set the locale priority of the late edition to 10; [list after everything else -- this would work with any number larger than 5]
Or maybe this:

Rule for choosing notable locale objects for the Misty Moorlands: repeat with item running through large things in the Misty Moorlands: set the locale priority of the item to 5.
Which, if it’s how it’s done is how it’s done (although doing this for every single room with notable objects seems like a huge bloody pain - assuming that notable objects means objects with initial descriptions, which is all I care about).

But, the number one thing I care about at this stage is ensuring that my NPC sidekick is always listed last out of the objects and people in the room (since he will be the least surprising thing to encounter in any location). I tried:

After choosing notable locale objects: set the locale priority of this bloke to 10.
And this:

Rule for choosing notable locale objects: set the locale priority of the handsome fellow to 10.
But now he shows up everywhere, even where he’s not.

Also, why is the syntax “set the locale priority to” and not “now the locale priority is”? Searching the docs for “set the”, it only seems to be used by locale priority.

Basically, you know, help please.

You could try Emily Short’s extension Room Description Control.

I haven’t looked at the wider issue, but I think I’ve got a quick solution to this:

You can test for his presence:

Rule for choosing notable locale objects: if the location of the handsome fellow is the location of the player: set the locale priority of the handsome fellow to 10.

Ah, clever. Thanks. I would still like to get to the root of this, but at least this much is solved.

Thanks. Would have expected this behaviour to be a part of core Inform though.

And the documentation leaves me with questions.

Does Inform not already separate people from objects?

Are objects with initial descriptions not already listed after the regular “you see a BLANK here” messages?

What decides the order by default? Is it just random?

And, um, how do you actually use this extension? I just added it and now objects aren’t getting listed at all.

EDIT: Example (spoiler’d for space):

[spoiler][code]“Test Game” by “C.E.J. Pacian”

Include Room Description Control by Emily Short.

The vague room is a room.

Fred is a man in the vague room.

The apple is a thing in the vague room.

Jabba the Hutt is a man in the vague room. “Jabba lounges here, corpulent and idle.”[/code]

[/spoiler]

In addition to Room Description Control, you have to include something like Ordinary Room Description (also by Emily Short). It pretty much restores Inform’s default behavior – but not entirely. You now need to give every object an initial appearance, or else it won’t be mentioned, you’ll see only a blank line feed. Ugly.

In the context of printing the room descriptions, no, I don’t think so.

AFAIK, the default sequence is:
first A) objects who get their own paragraphs (because the author made a “writing a paragraph about” rule for them or because he provided an initial appearance),
then B) the rest (“You can (also) see …”).
The order inside of step A and step B, respectively, equals the order in which the objects are created in the source text (experiment with the order of declarations in your example game to confirm this).

Like Jim said, you have to use it in conjunction with another extension by Emily. AFAIK, Room Description Control is just the framework. I’d recommend “Tailored Room Description”, because it doesn’t have the problem Jim mentioned. You can include it in your example game without having to add any other code, and you’ll get the object listing again (which you can then modify using the extension’s capabilities).

This was what I expected to be the case, but the fact that my sidekick is the last thing defined in the source code kind of disproved that to me. Maybe it’s because he moves around? He is the third thing defined for the room he’s in, but appears first in other rooms.

If that is the case at least on a room by room basis, then I guess that’s half my problem solved.

Thank you, I’ll give it a try.

This does seem like a lot of work for functionality that I’ve always considered pretty fundamental. I mean, what’s the point of trying to shape computer-generated text into a story if I can’t even control the order it’s output in?

I’m not sure it’s that simple.
As far as I can tell from the Standard Rules this is what happens:

Both A and B repeats through the Table of Locale Priorities. But this table is first created with blank rows for each thing in the game, then filled in by a choosing notable locale objects activity each time you look or enter a room etc.

At the before stage of the printing the locale description activity, the choosing notable locale objects activity puts the things in the room into the Table of Locale Priorities in the order they are “held” by that room and gives them all priority 5.

At the for stage of the printing the locale description activity, the Table of Locale Priorities is sorted in priority order.

I suppose that means that things with the same locale priority will remain sorted in the same order that they are held be the location – but I don’t know to what extent that coincides with the order in which those things are created in the source text (the list of things a room holds must change when you move things around, doesn’t it?).

If one manually sets the locale priority order of something, that thing will keep its place in the table (or end up last, if it wasn’t already in the table).
So I guess one has to see to it that manual settings of locale priorities take place after the standard notable objects rule (that sets the priority of everything to 5) and before the interesting locale paragraphs rule (that sorts the table in priority order).

You are right that it’s complicated, and I should probably have written “as far as I can tell” instead of “AFAIK”. Your analysis of what happens is helpful.
Still, I’m inclined to think that I was right about the equivalence. When I wrote the above, I did take the Standard Rules into account. I had experimented with the order of declarations, and the best explanation for the observed behaviour, as far as I could tell, seemed to be that the order in which the items are “held” by the location equals the order in the source text. There’s also a comment in an unrelated example (329, Hudsucker Industries, near the end) that seems to suggest something like this. It says there that we need to

The definition was: Two flamingly rude letters are in the satchel. Five polite letters are in the satchel.

Yes, as far as I can tell, when the player drops an object in a room, then the object will become the first in the “you can also see” list.

Yes, I think that’s the reason.

AFAICT, it’s the case.

Depending on your exact needs for customisability, you might be able to get by without the extension. I only mentioned “Tailored Room Description” because Felix and Jim had brought up the idea of using an extension.
Here’s a possible solution that I came up with, which doesn’t need an extension (but it’s probably not very elegant):

[spoiler][code]Importance is a kind of value. The importances are major, minor and petty.

A thing has an importance. The importance of a thing is usually petty.

The vague room is a room.

The candy bar is a thing in the vague room.

Fred is a man in the vague room.

The apple is a thing in the vague room.

Gloria is a woman in the vague room.

Jabba the Hutt is a man in the vague room. “Jabba lounges here, corpulent and idle.”

The handsome fellow is a man in the vague room.

The nonvague room is south of the vague room.

The tome is a thing in the nonvague room. “Your eyes are drawn to a leather-bound tome. What’s that doing here?”

Barbara is a major woman in the nonvague room. “A slender woman with short dark hair paces about, seemingly waiting to be >ASKed about herself.”

The necklace is a minor thing in the nonvague room. “You see a delicate necklace lying on the floor, glittering brightly.”

Every turn:
if the location of the handsome fellow is not the location of the player:
let the way be the best route from the location of the handsome fellow to the location of the player, using doors;
try the handsome fellow going the way.

Rule for choosing notable locale objects:
repeat with item running through major things in the location:
set the locale priority of the item to 1;
repeat with item running through minor things in the location:
set the locale priority of the item to 2.

After choosing notable locale objects:
if the handsome fellow is a notable-object listed in the Table of Locale Priorities:
now the handsome fellow is mentioned.
[This prevents the fellow from being printed twice.]

The list-the-sidekick rule is listed after the you-can-also-see rule in the for printing the locale description rules.

This is the list-the-sidekick rule:
if the location of the handsome fellow is the location of the player:
say “As always, there’s your trusty sidekick, the handsome fellow.”;
continue the activity.[/code][/spoiler]

You can specify the order in which things should appear by defining them as major or minor (so there are 2 levels of priority above the standard priority “petty”). I think the typing overhead is rather minimal in this setup, since you can just insert the importance as an adjective - “Barbara is a major woman” and so on.

The source/output order things seems to hold as far as I can see. Cool beans +1.

But Tailored Room Description is written in the second person, so it isn’t as simple as just dropping it into my project. Cool beans -1.

I can see that these messages are stored in tables in the extension source, but it’s not immediately obvious to me how to change them (largely because I’m trying not to learn about tables). I can’t find an example in the extension docs.

On the same subject, in your suggested code (and indeed, the priority lab code), the you-can-also-see rule seems to have been replaced or removed by Ron Newcomb’s CLM, as including it breaks them both.

I am such a sad panda right now. I really didn’t think my game was going to be very difficult to implement, but I feel completely out of my depth.

The you-can-also-see rule is gone. It must be brought. I do not have a rock.

EDIT: Okay, upshot of the thread: people said a lot of things that went over my head, BUT if I create objects in individual rooms in the order I want them to appear, then that will work, and I can have my sidekick appear last of all (except for the you can also see stuff) with:

After choosing notable locale objects: if(the location of the sidekick is the location of the player): set the locale priority of the sidekick to 10.
Although now that I think about it, part of my intended design was to expand the interact-able objects available to the player by creating them in nothing and moving them into locations after certain actions - which apparently scuppers the source code ordering thing. Maybe there’s a better way to hide objects until a certain point?

Looking through CLM’s source code, I see that Ron replaced the you-can-also-see rule with a rule called the “I-could-also-see rule”. So, if you use CLM, you’ll need to replace the following line in my example:

The list-the-sidekick rule is listed after the you-can-also-see rule in the for printing the locale description rules.

with

The list-the-sidekick rule is listed after the I-could-also-see rule in the for printing the locale description rules.

Then it should compile and the sidekick should appear last again. I just tested this, and it seems to work.

With regard to this:

If you decide to use my major/minor method from above, you can do the hiding as you described. If you flag the hidden objects as major or minor, they will, when they are moved to a room, appear first among the objects of their importance category in the location. You can try this out by adding the following to my example code:

[code]The stamp is a major thing. “I could spot a tiny blue stamp on the carpet.”

After taking the tome for the first time:
say “Amazing! A tiny stamp was hidden beneath the tome!”;
now the stamp is in the nonvague room.

The emerald is a minor thing. “The emerald that had fallen out of the necklace lay there.”

After taking the necklace for the first time:
say “As I picked up the necklace, an emerald fell from its setting.”;
now the emerald is in the nonvague room.[/code]

And that actually makes a crazy kind of sense, although I could have done without CLM’s default:

So, I got it working, but now there’s an issue with line breaks. As in, I need an extra one if there are “can also see” objects, but not if there aren’t. This is possibly because line breaks in I7 do my head in anyway.

No wait, that only happens when I include the CLM as well. Oh man.

Thank you for all your help. I’m sorry that I seem to have all the Inform 7 parts of my brain missing.

Can you put “[conditional paragraph break]” in before the “can also see” stuff? Line breaks confuse me too, and I’m not quite sure what “conditional paragraph break” actually does, but it sounds like it might help if you could figure out where they go.

Ron may or may not be checking this (I forget if he’s at PAX), so you might want to let him know about the CLM bug.

Further experimentation revealed that this can be fixed by adding the following code:

Table of custom library messages (continued) library-action library-message-id library-message-text going action 13 "[The person asked] [aux]arriv[e-s] from the [library message object][ignore library line break]"

Unfortunately, in this context it seems to do exactly the same thing as [line break].

I’ll shoot him an email.

Thank you. I’ll be replacing the default for this one anyway.

My WIP uses TRD with a different person; the code required to make it work with David Fisher’s CLM (which I think means it should work with Ron’s as well) is as follows:

[code]When play begins:
now the current-topic-sentences-table is the Table of NBS;
now the current-room-content-table is the Table of NRCD.

Rule for writing a topic sentence about an introduceable as-yet-unknown thing (called special-target) which is not in the location:
if the special-target is initially-described, make no decision;
if the special-target is flexibly-described, make no decision;
change the current-subject to special-target;
let special-exterior be the holder of the special-target;
say “[You] can see [a special-target] [in-on special-exterior as a possibly-known item]. [run paragraph on]”.

Table of NBS
disclosure
“[if the current-subject is a person][The current-subject] [is-are] here. [otherwise][You] can see [a current-subject] here. [end if]”.

Table of NRCD
disclosure
"[You] can [optional also]see [a list of mentionable things in the current-subject] [if current-subject is the location]here[otherwise]in [the current-subject][end if]. ".[/code]

I’m not going to get to it right away, but I’ve made a mental note that it would be nice to re-section Tailored Room Descriptions in such a way that it will dovetail politely with CLM. (Or if anyone else wants to do this, they are welcome.) I had the impression that I was the only user, so it wasn’t high on my priority list.

I think Tailored Room Description may be overkill for my purposes, if that takes the pressure off.

Apparently I should pay more attention to threads with Newbie in the title.

At the moment, several Going lines in CLM need be replaced:


Going action		8	"[The person asked] [aux][go*] up[ignore library line break]"
Going action		9	"[The person asked] [aux][go*] down[ignore library line break]"
Going action		10	"[The person asked] [aux][go*] [noun][ignore library line break]"
Going action		11	"[The person asked] [aux]arriv[e-s] from above[ignore library line break]"
Going action		12	"[The person asked] [aux]arriv[e-s] from below[ignore library line break]"
Going action		13	"[The person asked] [aux]arriv[e-s] from the [library message object][ignore library line break]"
Going action		14	"[The person asked] [aux]arriv[e-s][ignore library line break]"
Going action		15	"[The person asked] [aux]arriv[e-s] at [the library message object] from above[ignore library line break]"
Going action		16	"[The person asked] [aux]arriv[e-s] at [the library message object] from below[ignore library line break]"
Going action		17	"[The person asked] [aux]arriv[e-s] at [the library message object] from the [second library message object][ignore library line break]" 
Going action		18	"[The person asked] [aux][go*] through [the library message object][ignore library line break]"
Going action		19	"[The person asked] [aux]arriv[e-s] from [the library message object][ignore library line break]"
Going action		20	"on [the library message object]"
Going action		21	"in [the library message object]"
Going action		22	", pushing [the library message object] in front, and [us] along too[ignore library line break]"
Going action		23	", pushing [the library message object] in front[ignore library line break]"
Going action		24	", pushing [the library message object] away[ignore library line break]"
Going action		25	", pushing [the library message object] in[ignore library line break]"
Going action		26	", taking [us] along[ignore library line break]"

It’s surprising they all need the [ignore] when most actions don’t, but whatever.

But using arrive[-s] instead of arriv[e-s] was a total brain fart on my part.

I’ll poke around with the c-also-see rule’s linebreaking next.

I can’t seem to find any problems with line-breaking with that rule. I tried it with numerous objects, some with initial appearances, some with writing-a-paragraph-about rules, some with neither for “She could also see a horse there.” No problems found. Can someone create an example demonstrating it?