Question about speaking


Completely new to writing with Inform 7. I would appreciate some advice.

I’m looking to make a player be able to perform the command

Say {text}
Which appears in the game as ‘You say, “{text}.”’

Also, I would like to be able to have NPCs in the room pick up on specific words that the player says, for example.

You are in a room
Sylvester the Cat is here.

say I like cats
You say, “I like cats.”
Sylvester the Cat looks at you and says, “What’s that about cats? I’m the only cat around these parts.”

Thanks for your advice.

Another question.

I’ve been able to create a table to responses to “ask Sylvester about a topic.”

I’m trying to create a similar table to examine things in the room. But it does not appear to be working. Here’s my source text. The first line about the ears works in-game. The table causes an error (see below)

The ears are a part of Sylvester. Instead of examining the ears: say “Sylvester says, ‘I can hear you looking at my ears. That’s how sharp they are.’”

The tail is a part of Sylvester. The coat is part of Sylvester.
Instead of examining a object listed in the Table of the objects: say “Sylvester says, ‘[answer entry]’.”

Table of the object.
Object answer
“tail” “My tail is long and bushy.”
“coat” “I see you appreciate a healthy coat. Go on, pet it.”

Problem. You wrote ‘Instead of examining a object listed in the Table of the object’ , which seems to introduce a rule taking effect only if the action is ‘examining a object listed in the Table of the object’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

Am tabbing between object and answer. Have tried using other table titles.

Appreciate comments.

Did you re-type your source rather than pasting it in? I noticed you have a reference to “table of the objects” rather than “table of the object.” If you copy and paste, and put the whole thing inside code tags, it’ll be easier for people to evaluate your code.

Query one: Michael Martin’s Reactable Quips is a good extension for what you want to do. Look at the Security Consultant example in the extension, you’ll see that there’s a response for: “> say password”. It gives this response so long as you have “password” in the string of text following “say”. So, “say I know the password! It’s ‘password’” also works.

To have your "You say “{blah}” line will require a bit more trickiness. Perhaps someone else on the board knows an easy way to do this? (I’m thinking of reading the player’s command, and then stripping out the text that matches stuff like ‘tell x about’/ 'say / ‘ask about’ and then storing what remains as an indexed text that is then inserted before the player says anything. Sound about right?). I might wonder whether it really is necessary: the player has already typed ‘say blah’, so surely they know that the character has just said that.

Query two: There are ways of doing it in the way that you seem to want to, but why don’t you just have:

The ears are a part of Sylvester. The description of the ears is "Sylvester says, 'I can hear you looking at my ears. That's how sharp they are." Much easier, no?

It’s actually not that hard:

[code]Test is a room.

Bob is a man in test.

Instead of answering someone that:
say “You say ‘[the topic understood]’ to [the noun].”[/code]
If you want to mess around with capitalization and punctuation you might have to copy it to an indexed text, though.

That works great except it has to be a before rule, not an instead (otherwise you’d never get a response from anyone).

So Querada probably wants this:

Before answering someone that: say "You say, '[the topic understood]'"

Except, this isn’t quite in line with the brief: Querada wanted the player to be able to say something, and then have whoever was about give a response. What if multiple NPCs are about and they each have a response? Or Querada wants the player just to be able to say stuff regardless of whether there’s anyone around to hear it. Maybe a new action? Hmm.

Wouldn’t you have to use something like Eric Eve’s conversation packages for something like this? I mean, I guess you could do it without it, but doesn’t the extension include functionality for NPC response when they are the implicit interlocutor provided the subject is in their list of things to talk about? Unless you just want a random response from a random NPC to whatever you say or if there’s only a single NPC in the room…

I’m still trying to get my head around that extension, so I’ll be keeping an eye on the commentary.

Are you referring to the fact that an Instead rule stops the action? You can always add “continue the action” if that’s not what you want. Or you could handle the response within the Instead rule. But I came up with an alternative, for your consideration:

Speech Motivations is a work in progress, but it demonstrates how I think this sort of thing could be handled. The player’s action only deals with the PC’s actions (including speech). But it triggers all NPCs in the room to respond, and any of those who were addressed are flagged as “expected to respond.” During the Every Turn phase, those triggers are checked and the NPCs have their say.

Both Dr. Eve’s and my extensions are designed to handle conversation about in-game objects rather than pure-text topics. There’s very little in them to support or augment Inform’s built-in conversational actions, which all work with topics and set “the topic understood” to a snippet, which is a range of words within the player’s command. In contrast, the extensions usually define actions that discuss the second noun (and sometimes the noun, such as giving and showing), using Eric Eve’s “Epistemology” to define abstractions as “subjects” rather than text-topics.

I generally assume that anyone who is dealing with snippets is only implementing conversation within a limited context, and extensions are not all that useful for them.

I never use instead rules anymore: they act as special cases blocking the success of an action. Certainly you can ‘continue the action’ and so on, but that’s inelegant. Much better to use Check and Carry Out rules. Or at least, my collaborator Melvin assures me that this is good practice, I’m not sure whether this is an ideological matter if the results end up functionally equivalent.
[size=75][As a point of interest, in the 90K+ source of Calm there isn’t a single Instead rule][/size]

Ooh, I tried to get it to work. And it needed Scope Caching. So I got that off your site (because I am an elite detective I figured, correctly, that it’d be under “/Scope%20Caching.i7x”), but then Scope Caching wouldn’t work. So then I stared at Speech Motivations for a little bit. I can sort of see how you’ve gone about making it do. If it were to work, this would be an excellent conversation writing option for IF writers. You say it’s a work in progress: what doesn’t work yet?

To each their own, I suppose. Here are some considerations:

The Before, Instead, and After rulebooks run for every action (unless it is stopped, of course). That means each one of these rules will slightly slow down execution of each action, even if it is totally irrelevant. Check, Carry Out and Report rules only run for the actions they apply to, so they will have no effect on other actions.

However, if I understand correctly, the real slowdown is in starting up the rulebooks, not processing individual rules. And parsing tends to be slower than changing the world model or printing text. So unless your game is slow and you’ve identified the holdup as action processing, this would not be my first choice for optimization. On the other hand, if your rule really only applies to one action, there may be no reason use a Before, Instead or After rule.

Another disadvantage with Instead rules is that they bypass all the normal Check rules. This can be a huge pain in the butt, but occasionally it’s useful when the Check rules are too restrictive. Replacing Check rules may be faster than running Instead rules, but it may take up more memory. However, this situation may change radically in future versions of Inform, with the addition of the “X rule does not apply when…” feature to replace procedural rules.

Of course, the all-actions coverage of Before, Instead and After rules can be used to your advantage, if you wish to use action descriptions or kinds-of-action to catch many different behaviors…

Stopping a wide range of actions:

Instead of doing anything other than looking when the player is on the gurney:

Setting variables that apply to multiple actions:

Asking someone about is addressing the noun. Telling someone about is addressing the noun. Answering someone that is addressing the noun. Before an actor addressing the noun: Now the interlocutor of the actor is the noun.

Another consideration is the way Inform is expected to behave. Check and Report rules are not expected to change the world model. Carry out rules are not expected to output text unless the command was specifically a request for information with no side effects. Sometimes this is awkward, especially if variations in the action would necessitate action variables, which can’t be shared between different actions or scoped outside of action processing, even when the action delegates behavior to another rule or phrase. So it may make more sense to handle every stage of action processing with a single Instead rule for each different case.

As suggested by the previous consideration, grouping of concepts sometimes makes Before, Instead, or After rules easier to understand than a splintered array of specific action processing rules. Most commonly, authors use Instead rules for processing of specific objects:

Instead of doing anything other than drinking with the glass of water:

My rule of thumb is to use Instead for specific objects, but to define groups of objects that might fit into a specific action processing rule whenever possible:

A beverage is a kind of thing. Definition: A thing is drinkable if it is a beverage or it holds a beverage. Check drinking something not drinkable: say "You can't drink that!"

I do try to avoid Before rules. In my experience, they usually just interfere with Instead rules when you don’t want them to. But I make the exception for variable-setting as above.

Another action processing rulebook I’ve come to appreciate is the accessibility rulebook. It automatically covers wide ranges of actions, often in a well-targeted way. I recently wrote a “Flexible Action Requirements” extension to improve the targeting even more - but it’s probably slowing my game down quite a bit, so if speed is your goal, maybe that’s not such a super option.

Oh no! Well, first of all, thanks for volunteering as a beta tester! :laughing: It works for me - what I meant by it being a work in progress is that I haven’t decided to freeze the API yet. Well, that and I haven’t done any beta testing! :blush:

First of all, this tells me that I REALLY need to submit Scope Caching to the Inform site. But it doesn’t work? Double oh no!

I’d really like to help you get this working - it would help me a lot too. Can you post a short example of the problem, or at least the compiler error? If you don’t think it would be helpful for other people on this thread, or if it contains spoilers, you can pm me.


Oh, and one note: allows indexing, so you can see all my extensions there.

The way we’ve been working is to have general properties (A thing is either this or that. A thing is seldom that), even for one off items. That way it’s easy to implement new, similar items, into the game by giving the new item a bunch of properties (for instance, ‘The burnt bits of wood are medium, useless, dirty, soft and breakable’). All the game-interactions then require items with a given property or set of properties, that can be satisfied by any item that has those properties. One of the strengths of Inform is that it allows for so many different approaches.

I’m going to try it all again and make sure that I definitely installed the installation correctly. Then we can start a new topic on the forum to discuss the extension :smiley:

That didn’t take long. The problem arose on my side. Basically, when I downloaded it, I accidentally downloaded it as a html file, then I removed the tags and made it an .i7x file and somewhere along the line something messed up. Redownloaded it as an .i7x file and it works just fine. Incidentally, which version is the definitive version? (I assume the one that doesn’t have numbers after it).

Feh. Browsers! It seems like that’s the default now - for the browser to mangle your file when you save it.

That’s right. When I want to make an old version available, I make a copy with the numbers after it. The one without numbers is always the latest.

This is a good, flexible approach. More of your code becomes reusable, and you can also much more easily overlay new functionality on your game. For example, a hyperlink interface like this one can be set up to generate action buttons based on object properties, rather than via special-case coding. Avoidance of “instead” rules for action-handling, which you mentioned earlier, is also a good way to ensure that Inform properly tracks success/failure conditions, again giving you more flexibility should you want to overlay another interface with minimal additional code.


I’ve asked my friend Melv (who’s more code-savvy than I) to take a look at scope caching. In the meantime, now I’ve got it to work I’ll have a play around with Speech Motivations. Also, if it works just fine, you really should publish Scope Caching on the inform 7 website.

That hyperlink interface is amaaaaaaazzzing. This is how I want to make future games. Well, if it was a bit speedier. I can see exactly how the properties-based approach would make that easier: we even experimented with an auto-hinting system that worked the same as the suggested actions in the top right pane. (It ran too slowly and wasn’t very helpful in the way we implemented it so we’re jettisoning it in the next release).

Yes, you could also use properties to do a kind of general auto-hinting; might be useful to train newbies about what’s possible… You might want to check out Aaron Reed’s Intelligent Hinting extension (I think that’s the right title) for a relatively simple pseudo-AI hinting mechanism.

[ I should probably point out that most of the slowness with that hyperlink demo is due to its being on a web terp–the original web-playable Sand-Dancer is only a tiny smidge faster, at least on my machine. (Which suggests that the javascript interpreter is pretty speedy when it comes to lists and indexed texts, both of which are heavily used to create the hyperlink overlay.) It runs without any noticeable lag on a desktop terp, though it’s not very appealingly aesthetically. ]


I’m sorry… Gotta flag this.