Command to read a thing's properties.

Hello guys, I’m currently learning inform7 and trying to build an extension that simulates book objects with pages, bookmarks, spine and bookcover.

What I want in this example is for the player to enter “read book description of [book name]”, but when I enter the command in the story I get

so I came up with a carry out rule to have the program understand the command, but I get the following error:

[code]To say the default book description of (the book described - a book) (this is the say the default book description rule): if the book described is open, say “[The book described] is open.”; if the book described is closed and the book described is titled, say “[The book described] is titled ‘[the title of the book described]’.”; if the book described is closed and the book described is untitled, say “[The book described] is closed.”

Carry Out an actor reading the description of (the book described - a book): say the default book description of “[the book described]”.
[/code]

Now, I can use this hack to have the program read what I want (for title, cover, and spine):

Understand "read [book] description" as a mistake ("[title]"). Understand "read [book] title" as a mistake ("[title]"). Understand "read [book] bookcover" as a mistake ("[title]"). Understand "read [book] book cover" as a mistake ("[title]"). Understand "read [book] spine" as a mistake ("[title]").

But I know this isn’t the right approach to make this work.
Maybe I don’t understand correctly how to use phrases in rules, if you could point me in the right direction, I’d appreciate it lots. I’ve read documentation on carryout/report/check rules but when I apply them for this scenario I get all sorts of errors.

Here’s the first part of the code so you get the idea of what I’m trying to do:
pastebin.com/vugadKVA

I think one problem you’re having has to do with how commands get parsed. You have this snippet:

Reading is an action applying to one visible thing and requiring light. [...] Understand "read [thing]" as reading.
So if when you type something like “read book description of the dictionary”, the parser will look for a “thing” called “book description of the dictionary”. If there’s a thing called “dictionary” in the world, the parser identifies that in your string and tries to helpfully suggest a command that it can understand.

Similarly, check/carry out/report rules only apply to actions. So you can say “Carry out reading a thing” but you can’t say “Carry out an actor reading the description of (the book described - a book)” because “the description of (the book described - a book)” is not a thing, so it doesn’t fit with the definition of reading.

Also, it looks like you confused the “(the book described - a book)” construction, which I don’t think works at all for check/carry out/report rules, only for the “To X” rules (like “To say the default book description of”). So you would want to use the “(called the thing read)” construction like you did for the check rules.

An extremely simplified example that would do what you want would be something like:

[code]Reading the description of is an action applying to one thing. Understand “read the description of [something]” as reading the description of.

Carry out reading the description of a thing (called the thing read): say the default book description of the thing read.[/code]

(I think there are more complex ways to this that are probably better in the long run, but hopefully this gets the point across.)

My instinct would be actually to model the different parts as things, rather than work against the parser.

A bookpart is a kind of thing. A spine is a kind of bookpart. A cover is a kind of bookpart. 
Understand "description" and "blurb" as a cover. 
Understand "title" as a spine.

A book is a kind of thing. A spine is part of every book. A cover is part of every book.
A book has a text called the title. A book has a text called the blurb.

Instead of reading a spine:
	say the title of the holder of the noun.
Instead of reading a cover:
	say the blurb of the holder of the noun.

The main problem I can see with this is that Inform won’t recognize a command such as “read spine of dictionary” as referring to the object that it calls “dictionary’s spine”. I don’t know whether there’s an easy way to make that work.

Just add this:

Understand "of [something related by reversed incorporation]" as a bookpart.

Thanks.

Awesome. It worked. I appreciate everyone’s help. I finally got it to work the way I wanted. I really like inform but it’s sometimes hard for me to understand as documentation is limited. (and Stackoverflow has nothing on it ha)

Here’s the code, I had to edit it a bit to my needs (the code is longer than what I posted):

[code]Book - Books and Book Parts

[A book is a kind of container. It is openable. It is usually closed. It has some text called the title. The description is usually “[the default book description of the item described][run paragraph on]”.]

A bookpart is a kind of thing. A spine is a kind of bookpart. A cover is a kind of bookpart.
Understand “blurb” as a cover. Understand “read text” as a cover.
Understand “title” as a spine. Understand “description” as a cover.

A book is a kind of container. It is openable. It is usually closed. A spine is part of every book. A cover is part of every book. It has some text called the title. The description is usually “[the default book description of the item described][run paragraph on]”. A book has a text called the title. A book has a text called the blurb.

Instead of reading a spine:
say the title of the holder of the noun.
Instead of reading a cover:
say the read text of the holder of the noun.

Understand “of [something related by reversed incorporation]” as a bookpart.

To say the default book description of (the book described - a book) (this is the say the default book description rule): if the book described is open, say “[The book described] is open.”; if the book described is closed and the book described is titled, say “[The book described] is titled ‘[the title of the book described]’.”; if the book described is closed and the book described is untitled, say “[The book described] is closed.”
[/code]

I’d like to understand though, where @mikegentry got this, never seen anything like this before:

Works perfectly. But I do wonder where you guys get this vocabulary from.

Thanks

A lot of things are in the documentation somewhere, but aren’t easy to find unless you know just what you’re looking for. For this particular trick, see section 17.16 of WWI (“Understanding things by their relations”), and also Example 322 in the Recipe Book. You also need to know that “incorporation” is the relation that holds between X and Y when Y is part of X.

Pretty much everything is in the documentation, which is great for reading through start to finish, but pretty terrible as a reference. The IDE Index is also an incredible resource, but you have to put the time in to explore it. For example, the “Relations” panel of the “Phrasebook” tab gives you the machine-name of every built-in relation in the game.

Very true. There have been multiple times I’ve happened upon something amazing in an obscure example and gone “WAIT I CAN DO THAT?”

A good example is the alternate form of an if-statement where you can go “If x is:” and then precede every subsequent line with “just – 1, [do this]”…see I never remember how to format it, and I don’t use it often but when I do I have to go searching for it. There’s no “alternate ways to structure if-statements” chapter.

Surely someone has compiled a sort of Inform 7 syntax document of some kind.

Chapter 11 on “Phrases” is kind of this chapter. (This particular syntax is in the section on “otherwise.”) But it took me a bunch of searches before I remembered that “if” and “repeat” and all that stuff are in the chapter on “Phrases.”