[I7] Recreating part of Zork for a prologue, need advice

I figured that the problems I’m trying to fix ultimately fell into the same category, so I’ve provided a list for readers to follow along.

  1. Controlling the way an object’s contents are printed via the use of a scene

I have the entire Prologue of the game I’m working on wrapped up into a scene. The look and feel of the game are both changed after the player opens the mailbox and examines the leaflet inside. The traversal of the rest of the white house is completely optional, almost all objects are fixed in place, and passages like the staircase and the trapdoor are not present in the house; however, I want to keep the ‘game’ authentic by its presentation of the content that is implemented.

I’m having an issue with the way an object’s contents are printed using a scene. Here’s the code I originally used from the Inform version of Zork by Dean Menezes:

To say stuff in (O - an object): list the contents of O, with newlines, indented, giving inventory information, including contents, not listing concealed items, and with extra indentation.

and I implemented it by saying:

[code]To say stuff in (O - an object) when Prologue is happening:
list the contents of O,
with newlines,
indented,
giving inventory information,
including contents,
and not listing concealed items.

To say stuff in (O - an object) when Prologue is not happening:
list the contents of O,
as a sentence,
prefacing with is/are,
using the definite article,
giving inventory information,
including contents,
and not listing concealed items.[/code]

despite this, the parser says (these are the initial appearances in Kitchen):

On the table is an elongated brown sack, smelling of hot peppers. A bottle is sitting on the table.

and, when examined, says:

In the glass bottle is a quantity of water.

even though the code for the Prologue scene says:

Prologue is a scene. Prologue begins when play begins. Prologue ends when the player is in Bedroom.
  1. Implementing a supporter that lists the initial appearance of the items on top of it when examined

As I’m modeling this part of the game mainly off of the MS-DOS version of Zork, I noticed that in the Inform port the table is not implemented as an object in Kitchen, however in the MS-DOS version the table is fixed in place and a supporter. When it is examined, it only lists the sack’s initial appearance, the bottle of water’s initial appearance, and the :

>examine table On the table is an elongated brown sack, smelling of hot peppers. A bottle is sitting on the table. The glass bottle contains: A quantity of water

I appreciate the help, and I’m glad to see how far I’m progressing in my knowledge of Inform so far, as cliché as that might sound.

I believe that your code will create two new text substitutions, [stuff in (something) when Prologue is happening] and [stuff in (something) when Prologue is not happening]. In other words, you can’t put conditions on “to say” phrases like this.

Actually I’m surprised it compiles; do you actually have a [stuff in (something)] anywhere in your code? I’d have thought Inform would throw a “didn’t look like any form of ‘say’ that I know” error.

This should work.

To say stuff in (O - an object):
   if Prologue is happening:
       list the contents of O,
       with newlines,
       indented,
       giving inventory information,
       including contents,
       and not listing concealed items;
   otherwise:
       list the contents of O,
       as a sentence,
       prefacing with is/are,
       using the definite article,
       giving inventory information,
       including contents,
       and not listing concealed items.

I already put the text substitution into the initial appearance and it threw a ‘didn’t look like any form of say’ error, so I took it out.

I just put the substitution back into the initial appearance and changed my code, this is what I got:

A bottle is sitting on the table. a quantity of water

What code produces that?

"A bottle is sitting on the table. [stuff in bottle]"

That’s exactly what I’d expect it to do. It’s listing the contents of the bottle, which are currently “a quantity of water”.

Yes, it’s doing what it’s told. Try

"A bottle is sitting on the table. [line break]The glass bottle contains: [line break][stuff in bottle]". 

I’m not sure what you’re getting at, with the change of atmosphere after reading the leaflet. Is this a thing? In my version of Zork, the Kitchen looks exactly the same after reading the leaflet.

Edit: Oh, now I get it – this is something that happens in your game, not in Zork. (Slap on head.)

In any case, your dual version of [stuff in (thing)] won’t work well with my description above (or probably, with any one description). The “prefacing with is/are” option screws everything up. You’d need to change the description when the scene changes to make sense of it.

To get the indentation as in Zork, you need the “use extra indentation” option.

It still isn’t quite accurate, though, as the article in “A quantity of water” should be capitalized; but getting that effect consistently seems fairly complicated. If you care about it, here is one way. Maybe someone has something easier.

To say stuff in (O - a thing):
	carry out the listing contents zorkwise activity with O.

Listing contents zorkwise of something is an activity on things.
For listing contents zorkwise of a thing (called O):
	list the contents of O, with newlines, indented, giving inventory information, including contents, not listing concealed items, suppressing all articles, and with extra indentation.

Before printing the name of an improper-named thing while listing contents zorkwise: 
	say "[the expanded form of the indefinite article of the item described] " in sentence case.	

To say the expanded form of the indefinite article of (O - a thing):
	if the indefinite article of O is "":
		say "[if plural-named]some[else]a";
	otherwise:
		say the indefinite article of O.

When I tried implementing the table earlier, this is what I wrote:

[code]The table is an undescribed fixed in place supporter in Kitchen. On the table are the sack and the glass bottle.

The sack is a fixed in place closed openable container. “On the table is an elongated brown sack, smelling of hot peppers.”. Inside the sack is a lunch and a clove of garlic. The lunch and the garlic are edible.

The glass bottle is a fixed in place closed openable transparent container. “A bottle is sitting on the table. [line break]The glass bottle contains: [line break][stuff in bottle]”. Understand “bottle of [something related by containment]” as the glass bottle. A quantity of water is in the glass bottle.[/code]

In turn, an unnecessary line break is introduced between the initial appearance of the sack and the bottle:

[code]On the table is an elongated brown sack, smelling of hot peppers.

A bottle is sitting on the table.
The glass bottle contains:
A quantity of water
[/code]
How do I circumvent this?

(P.S: Draconis, the player won’t be able to go back to the Prologue area as of this draft; that’s why I wanted to keep the descriptions.)

The only way I can see is to replace the rule which is causing the break.

The use initial appearance in room descriptions rule does nothing.
For printing a locale paragraph about a thing (called the item)
	(this is the new use initial appearance in room descriptions rule):
	if the item is not mentioned:
		if the item provides the property initial appearance and the
			item is not handled and the initial appearance of the item is
			not "":
			increase the locale paragraph count by 1;
			say "[initial appearance of the item]"; [omitted paragraph break]
			if a locale-supportable thing is on the item:
				repeat with possibility running through things on the item:
					now the possibility is marked for listing;
					if the possibility is mentioned:
						now the possibility is not marked for listing;
				say "On [the item] " (A);
				list the contents of the item, as a sentence, including contents,
					giving brief inventory information, tersely, not listing
					concealed items, prefacing with is/are, listing marked items only;
				say "."; [omitted paragraph break]
			now the item is mentioned;
	continue the activity.

Probably you only want this to be in force during the Prologue (if I’ve understood your plan right). So maybe you want

The use initial appearance in room descriptions rule does nothing when Prologue is happening.
The new use initial appearance in room descriptions rule does nothing when Prologue is not happening.

(instead of the first line above).

There’s also a line break before the initial appearance of the sack, and this is harder to remove, since the rule causing it is written in I6 (called by “print the location’s description”). This is the best I can do, and it’s a bit clunky (and may have unforeseen side-effects).

The new room description body text rule is listed before the room description body text rule in the carry out looking rules.
The room description body text rule does nothing when Prologue is happening. 
The new room description body text rule does nothing when Prologue is not happening.
This is the new room description body text rule:
	if the visibility level count is 0:
		if set to abbreviated room descriptions, continue the action;
		if set to sometimes abbreviated	room descriptions and
			abbreviated form allowed is true and
			darkness witnessed is true,
			continue the action;
		begin the printing the description of a dark room activity;
		if handling the printing the description of a dark room activity:
			now the prior named object is nothing;
			say "[It] [are] pitch dark, and [we] [can't see] a thing." (A);
		end the printing the description of a dark room activity;
	otherwise if the visibility ceiling is the location:
		if set to abbreviated room descriptions, continue the action;
		if set to sometimes abbreviated	room descriptions and abbreviated form
			allowed is true and the location is visited, continue the action;
		say "[the description of the location]". [changed from: print the location's description;]

This is all terribly messy, and someone else might have a better suggestion.

But putting this together with the code in my previous post, I can produce a room description for the kitchen which is exactly like Zork!!! (Well, almost exactly.)

I’m getting a problem report for the if the possibility is mentioned condition existing and the possibility being marked for listing, how do I fix that?

Maybe a tabbing error? The line-wrapping on this site may have confused Inform. Try making sure that all of the lines are indented correctly.

That rule is just cut-and-pasted from the Standard Rules; I only deleted a couple of say "[paragraph break]"s . So if need be you could grab it from there and do your own surgery. (I indicated where I’d made changes in [comments].)

There’s still one problem that I’m troubleshooting: making a table that doesn’t interfere with the way room descriptions are printed.

[code][Here is the code that caused the problem that I commented out:
[The table is a fixed in place supporter in Kitchen. On the table are the sack and the glass bottle.

The sack is a fixed in place closed openable container. “On the table is an elongated brown sack, smelling of hot peppers.”. Inside the sack is a lunch and a clove of garlic. The lunch and the garlic are edible.

The glass bottle is a fixed in place closed openable transparent container. “A bottle is sitting on the table.[line break]The glass bottle contains: [line break][stuff in bottle]”. Understand “bottle of [something related by containment]” as the glass bottle. A quantity of water is in the glass bottle. Check attacking the glass bottle:
say “A brilliant maneuver destroys the bottle.”;
now the glass bottle is nowhere instead.
Check dropping the glass bottle when the player’s command includes “throw”:
try throwing the noun at the player instead.
Check throwing the glass bottle at something:
say “The bottle hits the far wall and shatters.”;
now the bottle is nowhere instead.]

[Here’s the code that printed the room description correctly, but doesn’t include the table:]

The sack is a fixed in place closed openable container in Kitchen. “On the table is an elongated brown sack, smelling of hot peppers.”. Inside the sack is a lunch and a clove of garlic. The lunch and the garlic are edible.

The glass bottle is a fixed in place closed openable transparent container in Kitchen. “A bottle is sitting on the table.[line break]The glass bottle contains: [line break][stuff in bottle]”. Understand “bottle of [something related by containment]” as the glass bottle. A quantity of water is in the glass bottle. Check attacking the glass bottle:
say “A brilliant maneuver destroys the bottle.”;
now the glass bottle is nowhere instead.
Check dropping the glass bottle when the player’s command includes “throw”:
try throwing the noun at the player instead.
Check throwing the glass bottle at something:
say “The bottle hits the far wall and shatters.”;
now the bottle is nowhere instead.]

[Transcript for the first version:]
Kitchen
This is the kitchen of the white house. A table seems to have been used recently for the preparation of food. A passage leads to the west. To the east is a small window which is open.
On the table is an elongated brown sack, smelling of hot peppers.

A bottle is sitting on the table.
The glass bottle contains:
A quantity of water

You can see a table here.

x table
On the table are a sack (closed) and a glass bottle (closed) (in which is a quantity of water).

[Second:]
Kitchen
This is the kitchen of the white house. A table seems to have been used recently for the preparation of food. A passage leads to the west. To the east is a small window which is open.
On the table is an elongated brown sack, smelling of hot peppers.
A bottle is sitting on the table.
The glass bottle contains:
A quantity of water

x table
You can’t see any such thing.
[/code]

You can declare the table as “scenery”, instead of “fixed in place”. Then it won’t get mentioned in room descriptions (unless you mention it yourself).

Looks like we need another rule change to suppress a line break, though:

The initial appearance on supporters rule does nothing.
For printing a locale paragraph about a supporter (called the tabletop) (this is the new initial appearance on supporters rule):
	repeat with item running through not handled things on the tabletop which provide the property initial appearance:
		if the item is not a person and the initial appearance of the item is not ""
			and the item is not undescribed:
			now the item is mentioned;
			say initial appearance of the item;
			say line break;
	continue the activity.

This is the transcript I got:

Kitchen
This is the kitchen of the white house. A table seems to have been used recently for the preparation of food.  A passage leads to the west. To the east is a small window which is open.
On the table is an elongated brown sack, smelling of hot peppers.
On the table is a glass bottle (closed) (in which is a quantity of water).

>x table
On the table are a sack (closed) and a glass bottle (closed) (in which is a quantity of water).

It seems like the code here is the culprit:

The use initial appearance in room descriptions rule does nothing when Prologue is happening. The new use initial appearance in room descriptions rule does nothing when Prologue is not happening. For printing a locale paragraph about a thing (called the item) (this is the new use initial appearance in room descriptions rule): if the item is not mentioned: if the item provides the property initial appearance and the item is not handled and the initial appearance of the item is not "": increase the locale paragraph count by 1; say "[initial appearance of the item]"; if a locale-supportable thing is on the item: repeat with possibility running through things on the item: now the possibility is marked for listing; if the possibility is mentioned: now the possibility is not marked for listing; say "On [the item] " (A); list the contents of the item, as a sentence, including contents, giving brief inventory information, tersely, not listing concealed items, prefacing with is/are, listing marked items only; say "."; now the item is mentioned; continue the activity.
but I don’t know what to change. I tried changing the phrase options to

list the contents of the item, with newlines, indented, giving inventory information, including contents, not listing concealed items, suppressing all articles, and with extra indentation;

and that had no effect.

Here is my complete code:

Kitchen is a room. "You are in the kitchen of the white house. A table seems to have been 
used recently for the preparation of food. A passage leads to the west 
and a dark staircase can be seen leading upward. A dark chimney leads 
down and to the east is a [small window] which is [if the window is open]open[else]closed[end if]."

The small window is a door. It is east of the Kitchen. The other side of the window is nothing. The window is open.
The table is a fixed in place scenery supporter in Kitchen. On the table are the sack and the glass bottle.
The sack is a container. "On the table is an elongated brown sack, smelling of hot peppers."
The glass bottle is a container. "A bottle is sitting on the table.[line break]The glass bottle contains: [line break][stuff in bottle]". 
A quantity of water is in the glass bottle. 

To say stuff in (O - a thing):
	carry out the listing contents zorkwise activity with O.
Listing contents zorkwise of something is an activity on things.
For listing contents zorkwise of a thing (called O):
	list the contents of O, with newlines, indented, giving inventory information, including contents, not listing concealed items, suppressing all articles, and with extra indentation.
Before printing the name of an improper-named thing while listing contents zorkwise: 
	say "[the expanded form of the indefinite article of the item described] " in sentence case.   
To say the expanded form of the indefinite article of (O - a thing):
	if the indefinite article of O is "":
		say "[if plural-named]some[else]a";
	otherwise:
		say the indefinite article of O.

The use initial appearance in room descriptions rule does nothing.
For printing a locale paragraph about a thing (called the item) (this is the new use initial appearance in room descriptions rule):
	if the item is not mentioned:
		if the item provides the property initial appearance and the item is not handled and the initial appearance of the item is not "":
			increase the locale paragraph count by 1;
			say "[initial appearance of the item]";
			if a locale-supportable thing is on the item:
				repeat with possibility running through things on the item:
					now the possibility is marked for listing;
					if the possibility is mentioned:
						now the possibility is not marked for listing;
				say "On [the item] " (A);
				list the contents of the item, as a sentence, including contents, giving brief inventory information, tersely, not listing concealed items, prefacing with is/are, listing marked items only;
				say ".";
			now the item is mentioned;
	continue the activity.
	
The initial appearance on supporters rule does nothing.
For printing a locale paragraph about a supporter (called the tabletop) (this is the new initial appearance on supporters rule):
	repeat with item running through not handled things on the tabletop which provide the property initial appearance:
		if the item is not a person and the initial appearance of the item is not "" and the item is not undescribed:
			now the item is mentioned;
			say initial appearance of the item;
			say line break;
	continue the activity.

The room description body text rule does nothing.
The new room description body text rule is listed before the room description body text rule in the carry out looking rules.
This is the new room description body text rule:
	if the visibility level count is 0:
		if set to abbreviated room descriptions, continue the action;
		if set to sometimes abbreviated	room descriptions and abbreviated form allowed is true and darkness witnessed is true:
			continue the action;
		begin the printing the description of a dark room activity;
		if handling the printing the description of a dark room activity:
			now the prior named object is nothing;
			say "[It] [are] pitch dark, and [we] [can't see] a thing." (A);
		end the printing the description of a dark room activity;
	otherwise if the visibility ceiling is the location:
		if set to abbreviated room descriptions, continue the action;
		if set to sometimes abbreviated	room descriptions and abbreviated form allowed is true and the location is visited: 
			continue the action;
		say "[the description of the location]". 

Whatever other horrors it might produce, it prints the following room description:

Unfortunately none of this will affect what gets printed for “x table”. I’ve modified the looking action, not the examining action. You’d have to go through the same process again with the examining rules. (Probably not difficult, but I’m out of steam.)

I took out the replacement of the use initial appearance in room descriptions rule as it didn’t change anything with my code other than breaking West of House’s initial appearance for the mailbox. The search supporters and examine supporters rules don’t seem to have the phrase options that I want to use. I just want to print the initial appearances of the sack and the bottle, but I feel like it would be lazy for me to manually type them out in the description for the table; after all, I intend to release the source text when the game is fully finished. What should I do?

Well, it depends just what you’re trying to do (I don’t think I’ve really understood yet). My code is designed to produce room descriptions like Zork. I haven’t tested enough to know whether it really succeeds at that; it works for the Kitchen at any rate.

If a substantial part of your game is going to be Zork-like, then you probably want something like this, but wrapped up in “switch” rules that let you turn Zork-mode on and off. The switching part isn’t hard to do (I suggested how earlier). You’d need to test the Zork-like mechanics thoroughly though, because I don’t have that much confidence in my code.

If you just have one short Zork-like scene, then probably it’s better to take a shortcut, like the one you suggest (putting everything in the table description manually). No point rewriting the whole of the looking mechanics just for one room description.

I decided to go the route I suggested, and I now have a near-perfect replica of the white house, with my own flair on certain objects as well. Thanks, I appreciate it!

Update: I assumed that adding a line break to the room description paragraphs about objects rule and only have it work during would let me have the lines stay without spacing and have one line before the command line in the Prologue, and while I got the desired effect in Prologue, the rule adds another line break in scenes where the Prologue isn’t running when I use it despite the code seeming to change the behavior in only that room.

The room description paragraphs about objects rule does nothing when Prologue is happening. The new room description paragraphs about objects rule does nothing when Prologue is not happening. Carry out looking (this is the new room description paragraphs about objects rule): if the visibility level count is greater than 0: let the intermediate position be the actor; let the IP count be the visibility level count; while the IP count is greater than 0: now the intermediate position is marked for listing; let the intermediate position be the visibility-holder of the intermediate position; decrease the IP count by 1; let the top-down IP count be the visibility level count; while the top-down IP count is greater than 0: let the intermediate position be the actor; let the IP count be 0; while the IP count is less than the top-down IP count: let the intermediate position be the visibility-holder of the intermediate position; increase the IP count by 1; describe locale for the intermediate position; decrease the top-down IP count by 1; say line break; [I added this line and experimented with different indentations.] continue the action.

Transcript for a room that is not involved in Prologue:

>LOOK
Bedroom (in the bed)
Unfortunately, sleep paralysis currently grasps you in its clutches, rendering you with only the ability to look around...


>

The scope of the rule should only be involved in Prologue (the SCENES command said that the Prologue scene wasn’t running), but it somehow spread to the scene that doesn’t involve that specific scene. What am I missing here?