Tables of text to match commands

I have two questions about using tables. I can get them to work except for two things. (Code below).
[1] How do I reply to asking about something if that something is not in the table. I would like the recipient of the question to look puzzled, or say “What?”. etc. I can’t find a phrase that responds to a missing topic entry.

[2] The user is likely to enter “Ask Barak about St. Cuthbert’s Chapel” but I cannot get the [.] or the [’] or the [apostrophe] into the topic entry. Even copying the phrase from the documentation for [apostrophe] does not work for tables. Suggestions?

After asking Barak about a topic listed in the Table of Briefing Answers:
	say "[answer entry].";	

Instead of asking Barak about nothing listed in the Table of Briefing Answers:
	say " 'What?' ";
Table of Briefing Answers
Topic	Answer
"room/inn/stables"	"Don't worry about it. It's been taken care of for you"  
"morning" or "leaving"	"At dawn, right after breakfast. You have a busy day ahead of you"
"breakfast/food"	"Probably not as good as this. I'll see what Bork can whip up"
"bork/bartender"	"Bork owns the Inn. He has served the king faithfully for years"
"chapel" 	"[description of chapel_answer]"  
"Cuthberts" 	"[description of cuthberts_answer]"  
"Triskelion/weapon"	"[description of Triskelion_answer]"
"team" or "former team"	"[description of team_answer]"
"previous team"	"[description of team_answer]"
1 Like

BIG EDIT: I assumed you were reporting correctly on the illegality of apostrophes in topics when I replied, but I did a test, and I was able to put an apostrophe in a topic name. It’s only your period that’s illegal in “St. Cuthbert’s chapel” as a topic. So keep that in mind when you read my post.

Re: point 2,

  • It’s a convention (in Inform 7 anyway, I can’t speak for all parser systems) that when a player types a period, that’s interpreted as meaning that they’re going to enter multiple commands on one line that are separated by periods.

e.g. north. eat pie. dance

So, if you’re happy to live within a widely known convention, you could subliminally indicate to the player not to type a period in St. Cuthbert’s Chapel by printing it on-screen as “St Cuthbert’s Chapel”. This is an easy solution.

  • What about the apostrophe? Well, in my WIP, I use Emily Short’s extension ‘Punctuation Removal’ to strip apostrophes from what the player types. This means that on-screen, and in printed names, you can still show apostrophes, but it’s optional for the player to type them.

A side-effect of doing this is that if you create an object with a name that uses an apostrophe. e.g.

Johnny's Apple is on the table.

The player will be unable to get a match with the word Johnny’s, because they are now unable to enter that word. What they type will become “johnnys”.

You get around this by including an ‘understand as’ line for the apple:

Understand "johnnys" as Johnny's Apple.

  • PS – Punctuation Removal can be used to strip periods, as well. You could use it to handle periods in exactly the same way I’ve just described you could handle apostrophes, and therefore print ‘St. Cuthbert’s’ on-screen safely, and store ‘st cuthberts’ behind the scenes for matching purposes. However, by stripping periods from player input, you remove the ability for the game to parse multiple commands on one line. Do a lot of people use this? I honestly don’t know. They may pipe up here if they do :slight_smile: The question is, would you be prepared to remove that convenience just to be able to print a period in St. Cuthbert’s? (Of course, you can print one now! But it may cue players to type the period, and then their command won’t work. That’s another Is It Worth Having That Happen for the sake of this period? question that only you can answer for your game)


1 Like

Thanks. There’s lots to think about here. However, I still cannot get the apostrophe to work:

"chapel"   "[description of chapel_answer]" 
"Cuthbert[apostrophe]s   "[description of cuthberts_answer]"

I get the following error:

**Problem.** I was unable to understand what you meant by the grammar token
 'apostrophe' in the sentence '"Cuthbert[apostrophe]s"' [![](blob:https:

In section 5.2 of the manual, it says

Instead of going outside, say "Lucy snaps, 'What's the matter? You don't trust my cookin['] mister?'"

I guessed that text in tables is handled differently. If not, any suggestions about including it.
I like Emily Short’s Punctuation Removal, but there may be unforeseen (by me) ramifications I need to think about before including it.

In another trial, I included
Understand “St Cuthbert’s” as Cuthberts.
I got an “Understand” error.
Perhaps I’m not setting up the table properly?

1 Like

This may be useful to many.
I included Punctation Removal by Emily Short but it seemed to make no difference.
When looking into the internal documentation of that extension, I found that it needs to be turned on, with:

After reading a command, remove stray punctuation.

I think the issue is that you’re working in two different contexts that handle apostrophes differently.

When you make code to ask inform to print text with a say phrase, the text has to be bounded by quote marks.

say "This is an apple.";

Within this context, we need a way to be able to actually print quote marks. But we can’t type them inside the other quote marks or it would look like this:

say "Polly says, "This is an apple."";

… which won’t compile, because Inform has no way to tell where the say phrase ends.

So within a say phrase, Inform’s default behaviour is to turn a typed apostrophe into a printed quote mark. To get the Polly phrase above to print, we’d use the code -

say “Polly says, ‘This is an apple.’”;

But now what if we want to actually print an apostrophe within a say phrase? This is where [’] or [apostrophe] come into play. Note they’re the same as each other, so you might as well use the short one, [’]:

say "Polly says, 'This is John[']s apple.'";

The final variation on this theme is that when you create a thing in your code, Inform is going to automatically created a matching printed name for it. So,

Lab is a room. Johnny's apple is in lab.

creates an object called Jonny’s apple whose printed name is “Johnny’s apple”. It’s a convenience (luxury?..) that when making things this way, you don’t have to format the apostrophes in any special way, simply because in the moment of making it, what they are and where they are (and that they aren’t allowed to be quote marks) is all unambiguous.

… Now we change subject from say phrases to topics in tables. Topics are special in that they’re not for printing, they are text to match player input against. An assumption about them is that the player is never going to type quote marks, but they might type an apostrophe. Therefore in this context, apostrophes are outright accepted. Therefore, in a topic, where you want an apostrophe, type it. There is no need for a workaround like [’]. So the following code compiles, apostrophe in Cuthbert’s and all:

Lab is a room.

Table of Briefing Answers
Topic	Answer
"St Cuthbert's chapel"	"Bork owns the Inn. He has served the king faithfully for years"

(Final caveat - of course, if you follow my first posts’s idea about removing apostrophes and Punctuation Removal and atll that, you would NOT include the apostrophe in Cuthbert’s in this topic, because that would prevent it from ever matching what the player typed!)

I hope this clears things up a bit.



Yes, that explains a lot. I[’]ll get it a try. lol

1 Like

It works with the apostrophe, as you said, and if St Cuthbert’s has no period. It doesn’t seem to matter whether Emily Short’s extension is used or not.