[i7] [SOLVED] Chairs (sitting, sitting in, getting up, etc.)

Hi intfiction.org! This is my first post here, so please bear with me.

I’m new to Inform 7 and am trying to implement chairs. I know there are extensions for chairs, but I’m doing this more as a learning exercise than anything else.

Here’s what I’ve got so far:

[code]“Chairs” by Stephen Ware

A chair is a kind of supporter. It is always enterable.

Report entering a chair (this is the report sitting in a chair rule):
say “You sit.”;
rule succeeds.
The report sitting in a chair rule is listed first in the report entering rulebook.
Report getting off a chair (this is the report standing up from a chair rule):
say “You stand up.”;
rule succeeds.
The report standing up from a chair rule is listed first in the report getting off rulebook.

Check an actor going when the actor is on a chair (this is the stand up from a chair before going rule):
say “(first standing up)[paragraph break]”;
silently try the actor exiting.
The stand up from a chair before going rule is listed first in the check going rules.

Understand “sit in [thing]” as entering.
Understand “sit down in [thing]” as entering.
Understand “sit [thing]” as entering.
Understand “get up from [thing]” as getting off.

The Patio is a room. “The front patio of your house is sparsely furnished, much like the house itself, which lies to the south.”.
The Foyer is south of the The Patio. “The foyer is small and empty.”.
the white plastic chair is a chair in The Patio. “Your one piece of patio furniture, a white plastic chair, is here.”.[/code]

Test with: sit in chair / look / get up from chair / sit in chair / go south

It’s working mostly they way I want it to, except for one problem: When you sit in a chair and “look,” the room description is:

"Patio (on the white plastic chair)".

I know this probably seems really stupidly minor, but I would like it to read:

Patio (in the white plastic chair)

How difficult is it to change the preposition “on” to “in” when the player is sitting in a chair?

I know that “on” is perfectly acceptable from a grammar point of view. This is not my actual game. The actual game is larger and being able to change these prepositions will matter; this is just a stripped-down example so that I could ask for feedback.

Any help is appreciated, and thanks to those who helped me get this far on the MUD.

This may or may not work in the actual game, but would making the chair a container be a quick solution?

Welcome, Stephen!

“(on the white plastic chair)” is what’s called a library message, which is a bit of default text that gets called in the Standard Rules somewhere. Currently you can change these using the extensions Default Messages by Ron Newcomb or Custom Library Messages by Ron Newcomb. (It’s my understanding that the next release of Inform will change this system radically.)

One way to find out which message this is is to type “rules” into the game prompt, run your test, and find that the message is being called by the “room description heading rule”; then you can open the Standard Rules and see how it calls the library messages. Another is to include one of Ron’s extensions, add the line “Use library message alerts.” to your source code, and run the test.

Or you could ask us – I’m just going through this in tedious detail in case you need to do something like this again. Anyway, it turns out that this is library message number 8 for the looking action. It looks like this:

Looking action		8	"[if the library message object is a supporter] (on [otherwise] (in [end if][the library message object])[ignore library line break]"

We can change this action by including a line that replaces this row of the Table of custom library messages with one that has the message we want, in a way that’s described in the documentation for Default Messages:

Table of custom library messages (continued) library-action library-message-id library-message-text Looking action 8 "[if the library message object is a supporter or the library message object is a chair] (on [otherwise] (in [end if][the library message object])[ignore library line break]"

And that should work! (Don’t forget to put in “Include Default Messages by Ron Newcomb.”)

Oh, and in case you want to copy the code from my post, there’s a trick to preserving the tab stops in code posted to the forum: Hit “quote” on the post you’re copying the code from and then copy the code out of the box you’d type your comment in. Otherwise all the tabs get turned into spaces, which would ruin the table.

Thank you for your fast and helpful reply! Your explanations were exactly what I needed.

Sadly, I’m not able to get the modified code to compile:

[code]“Chairs” by Stephen Ware

A chair is a kind of supporter. It is always enterable.

Report entering a chair (this is the report sitting in a chair rule):
say “You sit.”;
rule succeeds.
The report sitting in a chair rule is listed first in the report entering rulebook.
Report getting off a chair (this is the report standing up from a chair rule):
say “You stand up.”;
rule succeeds.
The report standing up from a chair rule is listed first in the report getting off rulebook.

Check an actor going when the actor is on a chair (this is the stand up from a chair before going rule):
say “(first standing up)[paragraph break]”;
silently try the actor exiting.
The stand up from a chair before going rule is listed first in the check going rules.

Include Default Messages by Ron Newcomb.
Table of custom library messages (continued)
library-action library-message-id library-message-text
Looking action 8 “[if the library message object is a chair] (in [otherwise if the library message object is a supporter] (on [otherwise] (in [end if][the library message object])[ignore library line break]”

Understand “sit in [thing]” as entering.
Understand “sit down in [thing]” as entering.
Understand “sit [thing]” as entering.
Understand “get up from [thing]” as getting off.

The Patio is a room. “The front patio of your house is sparsely furnished, much like the house itself, which lies to the south.”.
The Foyer is south of the The Patio. “The foyer is small and empty.”.
the white plastic chair is a chair in The Patio. “Your one piece of patio furniture, a white plastic chair, is here.”.[/code]

The error I’m getting is:

There needs to be a blank line between “Include Default Messages…” and “Table of custom…” Tables always have to be separated by a blank line from the rest of the text, both before and after.

Ahh! I figured it was something small like that. Thank you all so much for your help; it works great!