I would like to be able to respond when the player says certain things, but saying doesn’t seem to be a recognised verb and neither is talking or speaking. But inside the game, I can type: Say “Hello”. I just can’t seem to find any way to respond to it in my program.
When the player types SAY, Inform understands that as the action “answering it that” - like, answering (some thing or character) that (some topic). So that’s the action you’ll want to write rules for (note that if no one else is around, it defaults to thinking you’re saying the topic to yourself).
One cool trick is that when you’re testing your game, you can type ACTIONS and then you’ll get a line of output telling you what action Inform processed your input into - it can be really handy for cases like this!
ACTIONS and similar commands are mentioned in Writing with Inform, §24.3. High-level debugging commands, btw.
Though it reports answering the man that "hello"
, so I’m not quite sure how you’d realize that the generic action is answering it that
…
Very true! Maybe it’s helpful to mention that the other resource I find super helpful for issues like these is @zed’s page accessibly displaying the Standard Rules. Between ACTIONS and CTRL-Fing through that, it’s usually not too hard to get at least a basic grounding in what’s going on.
In addition to what’s been mentioned, the Index tab in the IDE can be very helpful. Under the “Actions” sub-tab, there are several ways to see the actions recognized by the game. On the “Commands” sub-sub-tab, you can see which commands the player can type and what the corresponding action is, and follow the chain from “say” to “answer” to “answering it that” (by clicking on the small magnifying glass icon).
Here’s a small example how one might implement some responses:
The Lab is a room.
Alice is a woman in the lab.
After answering Alice that "hello/hi":
say "She smiles and says, 'Hello, what's up?'";
After answering Alice that "bye/goodbye":
say "She waves goodbye.";
This leaves the standard “There is no reply.” response in place for any other topic.
For NPC conversation in general, there are several helpful chapters in the Recipe Book: 7.6. Getting Started with Conversation (and following).
If you’re doing this a lot, one of the most handy extensions is Eric Eve’s “Conversation Responses” which lets you just write rules about asking, telling, showing, giving, asking for, saying yes or no, saying hello or sorry. You can define responses to specific objects or other characters, object types like “Response of Bob when asked about a container”, explicit text or tokens.
Detail
Greeting response for Bob:
Implicit greeting response for Bob:
Farewell response for Bob:
Implicit farewell response for Bob:
Response of Bob when asked about Bob:
Response of Bob when asked about “life”:
Response of Bob when told about “[money]”:
Response of Bob when asked about a container:
Response of Bob when asked about something fixed in place:
Response of Bob when told about Jim:
Response of Bob when shown the wallet:
Response of Bob when given the wallet:
Response of Bob when asked for the wallet:
Response of Bob when asked for “sympathy”:
Response of Bob when anwered that “probably”:
Response of Bob when saying yes:
Response of Bob when saying no:
Response of Bob when saying sorry:
Response of Bob when asked-or-told about “life”:
Response of Bob when asked-or-told about the wallet:
Response of Bob when given-or-shown the gold coin:
So you’d write something like:
Greeting response for Bob:
say "'Oh hey there,' he responds.";
Implicit greeting response for Bob:
say "Bob is startled from his reverie when you speak to him with no warning.";
Response of Bob when asked about bob:
say "'Oh, I'm nobody special,' he intones.";
increase pity by 1.