[I7] Missing noun while consulting it about

I really want to allow the player to abbreviate the consulting command (among other related commands) to eg “look up pavlova” but I’m struggling to apply the examples for supplying missing nouns to this case. When I try the following minimal code:

[code]The Library is a room. A book is in the Library.

Understand “look up [text]” as consulting it about.

Rule for supplying a missing noun while consulting:
now the noun is the book.

Instead of consulting the book about “pavlova”:
say “It claims pavlovas were invented in Australia: clearly this book cannot be trusted!”[/code]

it fails to compile with the error:

If I remove the “understand” rule it compiles and “consult book about pavlova” works fine, but “look up pavlova” predictably throws an error.

(I’m also fuzzy about “consulting” vs “consulting it about”, but the compiler throws a different error if I have “while consulting it about”, or if I have “understand … as consulting”, so I assume that this way around is correct in that respect at least. For whatever reason.)

Am I missing something; or is there, shall we say, a gap in Inform’s functionality here?

I think you can only supply a missing noun with one-noun-only activities. Inform doesn’t know that, in the incomplete grammar line, it’s the first noun that’s supposed to be missing. You can see why this would be a problem with actions applying to two things; with actions applying to a thing and a topic it would in theory be unambiguous, but it doesn’t work.

The thing is that it’s almost never worth fiddling with supplying a missing noun/second noun to get it to work right–these can be convenient but if they’re not convenient you can basically always work around it with a new action. So you could do this:

[code]Consulting vaguely is an action applying to one topic. Understand “look up [text]” as consulting vaguely.

Check consulting vaguely when the player cannot touch the book: say “You can’t find the book.” instead.

Carry out consulting vaguely: try consulting the book about the topic understood.[/code]

Curiously I can get a missing noun to work when the action takes two things, though it requires a bit of finessing as when there’s one noun Inform naturally assumes that it’s the second noun missing. eg adding the following code:

[code]Definition: a person is other if it is not the player.
The librarian is a woman in the Library.

Understand “ask [someone] about [something]” as interrogating it about. Interrogating it about is an action applying to two visible things.

Rule for supplying a missing second noun while interrogating:
if the number of other people in the location is 1:
now second noun is noun;
now noun is a random other person in the location.

Understand “ask about [something]” as interrogating it about.

Instead of interrogating the librarian about the book:
say “‘I’ve been meaning to weed that, actually,’ she says.”[/code]

So it seems to be just an issue when one of the “nouns”/parameters/arguments is a topic instead of a thing. (Oh: I’m reminded of something else I struggled with, that when you’re working with stored actions, you can refer to eg the second noun of the action, but if it’s a topic it returns “nothing” instead, and there’s no documented way to refer to the topic parameter.)

A shame, but creating a new “consulting vaguely” action sounds like the perfect way around this, thank you!

Oh, that’s a clever way of using the supplying a missing second noun activity to effectively supply a missing noun for two-thing activities! What I meant was that there’s no way to get the supplying a missing noun activity to run here, but you can use that to put the noun the player entered into the second-noun spot.

As for accessing the topic parameter in a stored action, I poked around in the Inform 6 templates a bit, and I found this:

This makes it sound like it wouldn’t be straightforward to access the topic as a snippet (which is what “the topic understood” really is–there’s some more discussion of that here, with more discussion about what topics are farther down if you’re a glutton for punishment). Snippets are always treated as excerpts of the current command–they’re just stored as a number that tells you which word the snippet starts on and how many words it goes. It seems from the I6 templates that when a stored action involves a topic, Inform stores the whole command (or maybe just the words from the relevant snippet) as text as part of the stored action. Then if it ever needs to refer back to that, it copies the current command into a buffer, loads the old stuff into the current command, does whatever it needs to do in order to retrieve the old topic understood as a snippet, and reloads the current command from the buffer.

It seems very complicated!

The flip side of this is that the snippet (topic understood) is a subset of the player’s command. The only useful thing you can with it is match it against topics (usually expressed in a table). So it’s often possible to do the matching right away, and then store a table line or associated game object rather than trying to store the snippet.

If I may jump in with my own relevant (?) story. I am in the middle of getting a tv set to work and the player being able to change the channels.

I start with a “changing it channel to” to get player commands like “change/switch/turn [something] to channel/-- [number]”.

Then, I want to also get the cases where the player omits either or both parts, as in:

  • change channel to 3 (noun missing)
  • change television channel (number missing)
  • change channel (both number and noun missing)

I am up for making separate actions for each case. For example, if the number is missing, the relevant action can increment the channel number; if the noun is missing, the “check rule” checks whether the television is in the location.

I have never successfully used the “supplying a missing noun” solution, so I am not aware of the drawbacks. Nevertheless, I must admit that the multiple action solution can get a little tedious in such a case.

The other thing is that I don’t know how to get the game to prompt for missing snippets, as the default actions do, for example:

I have no idea how to achieve this. Moreover, if I catch missing snippets with actions that don’t regard them as missing, I probably cannot get my game to make such interactions, where the player can complete her sentence with multiple prompts.

(If this is irrelevant, I apologise; feel free to make it into a separate post.)

@zarf - My problem is that I’ve got more columns than the basic topic/reply table so that I can track whether it’s something someone might only confide in you once they trust you, and whether or not they’ve already said it so they can chide you, and such like. Which makes the corresponding rule more complex, which means I don’t want to have to repeat it elsewhere and risk the two locations getting out of sync if I tweak things.

I could possibly do something fancy with shifting that complexity into an activity which writes at least the textual output into a global variable which the report rule prints immediately, while the “3 turns from now” rule prints only later. It feels like a kludge, and I don’t like global variable for kludgy purposes because I suspect them of breeding while my back is turned, but otoh if it works…

I’ve also toyed with the idea of adding a “unique key” column to the table so I could store that, but that seems overkills and a maintenance nightmare.

My solution for now is to sit down and take a hard look at my story and tell myself very sternly that I don’t actually need this function, I just want it, and I can deal with this particular scene a different way. :slight_smile:

@GiannisG - For the first one, I’d first consider whether you really need a noun other than the number. If the only thing in your story world whose channel can be changed is the television, then just a changing to [number] rule should do the job and let the rule (rather than the player) specify the TV - then the “supply a missing noun” rule becomes a lot simpler.

But if you also have radios, and elevators going to different floors, and ovens at different temperatures, then you might want a generic rule that can cover all these cases, and then you do need a changing [something] to [number] rule – and, playing around with it somewhat, I think trying to write a missing noun rule is going to run into the same problem with numbers than I have with topics.

What I’d do would be pick the command I want the player to use (probably the shortest version I can think of as no-one wants to be typing extra words) and then use the item’s description to encourage them to use it, eg

x tv
The television is an old black-and-white box complete with bunny-ear antennae. It has four buttons to let you switch the channel. It is currently switched to 4.

Then you don’t have to worry about “change/turn/set/select” because you can rely on the player echoing your own words by using “switch”. They might try “switch tv/television/channel/it to 3”, or possibly even “switch to channel 3”, but those seem less likely and are few enough to be dealt with by, oh…

Understand "switch to [number]" as switching to. Understand "switch tv to [number]" as switching to. Understand "switch television to [number]" as switching to. Understand "switch it to [number]" as switching to. After reading a command: if the player's command includes "channel", delete the matched text.

Or if you do want/need to include the tv as a noun then:

Understand "switch [something] to [number]" as switching it to. After reading a command: if the player's command includes "channel", delete the matched text. Understand "switch to [number]" as a mistake ("You need to say what you're switching."). Understand "switch [something]" as a mistake ("You need to say what number you're switching it to."). Understand "switch" as a mistake ("You need to say what number you're switching it to.").

I’m not clear on how to get the computer to prompt for missing nouns either. Running a “rules all” command before a “take” I see it does consult the “does the player mean” rules first. Emily Short’s “Overview of rules consulted in play” mentions the “asking which do you mean activity” - this is in the documentation at 18.31 but I can’t see how to intentionally invoke it.

[code]Understand “switch to [number]” as switching to.
Switching to is an action applying to one number.
Understand “switch” as switching to.

Report switching to:
say “Now the television is switched to the channel [number understood].”[/code]

gives me the curious response "You may not name an object - since the same code happily tells me “You must name a noun” when I change all the ‘numbers’ to ‘things’ I suspect Inform may not deal well with non-things here either, and using the “understand” rules may be your best bet.

Well, as a matter of design, you can’t rely on this! Players will use whatever word is stuck in their heads and it’s best to catch as many synonyms as possible.

As for prompting for missing nouns, you’re entirely right–Inform doesn’t deal with non-things well here. For my sins I have spent a little time poking around the disambiguation code, and it’s in the parser internals under “NounDomain” if I remember correctly, which is the part of the parser that tries to resolve snippets into nouns–it finds things that match, runs Does The Player Mean rules and those obscure rules that default to things you’re holding, and if there’s still a tie it runs the disambiguation activities. So those just don’t work for non-nouns.

I looked in the I6 templates to see where the curious response you got came from and encountered this annotation:

The thing you did falls under (iii), so it looks like you accomplished something that’s supposed to be fairly difficult! But yeah, it looks like this won’t work for these purposes.

…as for supplying a missing noun in commands like “ask about vinegar,” I hacked this up that’s meant to simulate that:

[code]Lab is a room. Debbie Downer and Pollyanna are women in Lab.

Instead of asking Debbie Downer about something, say “Debbie says, ‘Oh, [the topic understood] won’t turn out well.’”

Instead of asking Pollyanna about something, say “Pollyanna says, ‘Yay, [the topic understood]!’”

Vaguely asked is a truth state that varies. The stored topic is a text that varies.

Vague asking is an action applying to one topic. Understand “ask about [text]” as vague asking.

Carry out vague asking:
say “Who do you want to ask that?”;
now the stored topic is the substituted form of “[the topic understood]”;
now vaguely asked is true.

Supplying a missing person is an action applying to one thing. Understand “[person]” as supplying a missing person when vaguely asked is true.

Carry out supplying a missing person:
now vaguely asked is false;
try asking the noun about “[the stored topic]”.[/code]

I was kind of surprised that the last line worked, directly trying asking about with a text substitution, but it does, so yay! (I wouldn’t count on this not to break though.)

You do, said the narrator.