Help me with a table please

I’m trying to look up a subject in a table based on player’s input.

consulting about is an action applying to two things.  understand "consult [something] about  [something]" as consulting about.

instead of consulting about:
	if noun is not metal book:
		say "I don't have anything to consult with.";
	otherwise:
		repeat through the Table of Metal Book's responses:
			if second noun is the consult entry:
				say "The book buzzes and clicks and then a male computer's voice says '[response entry]'."

Table of Metal Book's responses
Consult	Response
"therapist"	"Dr. Gehardt V. Workinger.  Born 1924 in Vienna Austria.  A noted disciple first of Freud and then Jung...
2 Likes

“Consulting it about” is a default action in Inform 7. It applies to one thing (the game object being consulted) and one topic (not a game object, but a bit of text, the subject being looked up).

Your new “consulting about” action applies to two things, two game objects. It will only work if the “second noun” is also an object visible to the player, like if you’re standing in front of a statue and you consult your tourist guide about the statue.

But in your Table of Metal Book’s responses, the “Consult” column contains text in quotes. The text string "therapist" is distinct from any game object like The therapist you may have introduced. When your rule repeats through that table, it will never identify “the second noun” of the current action as a text string, because “the second noun” is necessarily a game object.

Unless you’re doing something really wild*, the built-in “consulting it about” action probably meets your needs. (It has “look up…” and other synonyms already prepared for you, which is nice.) Instead of defining a new action, you can just add:

Instead of consulting the metal book about a consult listed in the Table of Metal Book's Responses: 
    say "[response entry][paragraph break]".

To make this rule recognize the “consult” column correctly, you have to specify in the table heading that the column is for topics, by adding “(a topic)” like so:

Table of Metal Book's responses
Consult (a topic)	Response
"therapist"	"Dr. Gehardt V. Workinger.  Born 1924 in Vienna Austria.  A noted disciple first of Freud and then Jung..."

Or you can just use the word “topic” in the rule and as the column name, which is how examples in the documentation do it:

Instead of consulting the metal book about a topic listed in the Table of Metal Book's Responses: 
    say "[response entry][paragraph break]".

Table of Metal Book's responses
Topic	Response
"therapist"	"Dr. Gehardt V. Workinger.  Born 1924 in Vienna Austria.  A noted disciple first of Freud and then Jung..."

There’s a small implementation issue in this example that I should address so that nobody calls me out on it. A player who types >LOOK UP WORKINGER IN METAL BOOK will get no response, because there’s no “workinger” line in the table. But you can add synonyms like: Understand "therapist" and "gerhardt" and "workinger" as "[therapist]". Then you just have to add those brackets to the table:

Table of Metal Book's responses
Topic	Response
"[therapist]"	"Dr. Gehardt V. Workinger.  Born 1924 in Vienna Austria.  A noted disciple first of Freud and then Jung..."

I’m getting most of this from the “Costa Rican Ornithology” example here.

*There was a (now direly unappreciated) game released about ten years ago that did something really wild along these lines, but we don’t have to get into it here.
5 Likes

Although Afterward’s advice is to be taken seriously, it suggests a different direction (using topic-based inquiries) than what you’ve set out to do (using object-based inquiries). In case you still want to pursue your original approach, here are some things to note:

  1. A given action name can only be used with a particular set of “parameters,” which are what can qualify as the noun or second noun. The built-in consulting it about action applies to one thing and one topic, so you can’t make it apply to two things. You need to create your own action definition, e.g. Inquiring with it about is an action applying to one thing and one visible thing. Specifying “visible” for the second noun will paradoxically allow asking about things not in view of the player character. Using “it” in the action name is important for two-noun actions.

  2. You’ll also want to disconnect all of the pre-existing command words from the built-in consulting it about action. This easy enough: Understand nothing as consulting it about. (See WWI 17.3 Overriding existing commands for details.)

  3. You then need to specify the grammars that can be used with your new action. (See WWI 17.1 Understand, WWI 17.2 New commands for old grammar, and WWI 17.4 Standard tokens of grammar for more.) To replicate what was the built-in grammar for consulting it about:

Understand "look up [anything] in [something]" as inquiring with it about (with nouns reversed).
Understand "consult [something] on/about [anything]" as inquiring with it about.
Understand "read about [anything] in [something]" as inquiring with it about (with nouns reversed).
Understand "read [anything] in [something]" as inquiring with it about (with nouns reversed).

After that, you should be able to write the rules that you want to in a natural way:

Instead of inquiring with the metal book about the glowing crystal:
	...

or to use your table-based approach:

Instead of inquiring with the metal book about something: [takes precedence when there is no entry]
	say "The metal book speaks robotically: 'No data available.'"

Instead of inquiring with the metal book about a subject listed in Table of Subjects:
	say "The metal book speaks robotically: '[response entry]'".

Table of Subjects
subject	response (text)
glowing crystal	"<exposition about the crystal>"

Note that you probably don’t want to be using Instead rules like this in the long run, but that will get you started. Also note that topic-based inquiries are totally disabled in this approach – I wouldn’t really recommend trying to mix them.

2 Likes

Which game? Do tell!

1 Like