Plz Halp: Trying To Suppress Certain Printed Text (Complete source included, critique welcome)

So in bed last nite I had some ideas about making an object like a trunk which can have stuff both inside it and on top of it. And which, if opened while items are on top of it, the items fall off.
Well, those ideas didn’t exactly work out right LOL (using Before, Instead, and After)
So I came up with something else, using Check, Carry Out, and Report. I also added flexible descriptions to both the trunk and the room to describe what is in or on it.
The problem I’m having is how it keeps printing “(the Trunk)” every freakin command involving the trunk. How do I suppress that? I’m not sure where in the process that gets printed, or even what is printing it, or why.
Example game interaction:

>x trunk
(the Trunk)
Your standard green metal trunk, which is open.

>close trunk
(the Trunk)
You close the Trunk.

>x trunk
(the Trunk)
Your standard green metal trunk.

>take stuff
Taken.

Comments and critiques on the code are appreciated, as I’m still pretty n00b with Inform 7.
Also, what about that commented out Tables section? I was thinking I could simplify my Check, Carry Out, and Report code by checking tables for both the trunk inside and trunk top to determine which actions would apply to which trunk part. It would make it easier to add more actions, rather than having to write more Check, etc… rules. Or maybe that idea isn’t workable. S’why I’m asking.
COMPLETE SOURCE:

"Supporter Containers - The Trunk" by "V.C.Stegeman"

Volume - Setup

Book - Bookkeeping

Part - Initialization

Use no scoring.
Use American Dialect and the serial comma.

The story headline is "Supporter Container".
The story description is "Things on the trunk fall off if the chest is openened after the player is warned about it. The game autoreports things on or in the trunk as appropriate.".
The story genre is "Learning".
The release number is 1.
The story creation year is 2021.

Book - Tables (Could this be used to hold a list of actions respective of the part being interacted with)

[
Table of Trunk Interior
options
"inserting it into"
Table of Trunk Top
option
"putting it on"
]

Book - Geography

Part - Map

The Laboratory is a room. The description is "[lab description]".

To say lab description:
	Say "Clean white empty walls everywhere. Smack in the middle of the floor is";
	If the Trunk Interior is open:
		Say " an open green metal trunk.[If something is inside the Trunk Interior] Inside the trunk is [a list of things inside the Trunk Interior].[no line break]";
	Otherwise:
		Say " a green metal trunk[if something is on the Trunk Top]. On top of it is [a list of things on the Trunk Top][end if].[no line break]".

Book - People

The player is a person in the Laboratory.

Book - Things

Part - The Trunk

The Trunk is in the Laboratory. It is scenery. It is unmentioned. The description is "Your standard green metal trunk[trunk description].".

To say trunk description:
	If the trunk interior is open:
		Say ", which is open[If something is inside the Trunk Interior]. Inside it is [a list of things inside the Trunk Interior][end if]";
	Otherwise if something is on the Trunk Top:
		Say ". On top of it is [a list of things on top of the Trunk Top]".

The Trunk Interior is part of the Trunk. It is a container. It is openable. It is closed. The printed name is "Trunk".
The Trunk Top is part of the Trunk. It is a supporter. The printed name is "Trunk".

Check opening the Trunk:
	Now the noun is the Trunk Interior;
	Continue the action.

Carry out opening the Trunk Interior:
	If something is on the Trunk Top:
		Say "As you open the trunk [a list of things on the Trunk Top] falls off it and onto the floor.";
		Repeat with Item running through list of things on the Trunk Top:
			Now the Item is in the Laboratory;
		Now the Trunk Interior is open;
		Stop the action;
	Otherwise:
		Say "You open the trunk.";
		Continue the action.
		
Report opening the Trunk Interior:
	Stop the action.

Check closing the Trunk:
	Now the noun is the Trunk Interior;
	Continue the action.

Check inserting something into the trunk:
	Now the second noun is the Trunk Interior;
	Continue the action.
	
Check searching the Trunk:
	Now the noun is the Trunk Interior;
	Continue the action.
	
Check putting something on the Trunk:
	If the Trunk Top is open:
		Say "You can't put things on the trunk while it's open." instead;
	Otherwise:
		Now the second noun is the Trunk Top;
		Continue the action.
	
Report touching the Trunk:
	Say "The outside of the trunk feels rough and metalic. And cold[If the Trunk Interior is open]. A smooth cloth of some sort lines the interior[End if]." instead.
		
Part - Various Simple Items

The Stuff is a thing in the Laboratory. The indefinite article is "some". The description is "Just some stuff."

The Gadget is a singular-named thing in the Laboratory. The indefinite article is "the". The description is "Just some gadget."

Volume - The Game Itself

Book - Testing Commands - Not for release

Test me with "take all/put gadget on trunk/examine trunk/open trunk/put stuff in trunk/examine trunk/close trunk/examine trunk/look/open trunk/look/close trunk/put gadget on trunk/look"

Test supporting with "take all/put all on trunk/examine trunk/open trunk"


Book - Game Play

DELETED POST
I thought I’d simplified something, but doing so caused another problem. So never mind.

EDIT: In so doing, however, I did discover a bug. If nothing was on the trunk, the Trunk Interior object didn’t actually get opened. Derp. Fixed.

1 Like

The text in parentheses after the player command is a disambiguation message. Disambiguation is the process that the parser goes through when trying to decide which thing is the one to which a command refers, in cases where the text supplied in the command leaves ambiguity. In this case, there are three objects with names that match the word “trunk”: the Trunk, The Trunk Interior and The Trunk Top.

The details of disambiguation can be somewhat involved, but in this case the operative factor is probably that the Trunk (main object) is closer to the player in the internal object tree because the other two objects are its children.

If you don’t intend that the player should be able to separately interact with the top or interior, then making these objects privately-named (see WWI 17.17 Context: understanding when for details) may do the trick. That will make “trunk” apply only to the main object and preclude the need for disambiguation.

3 Likes

You nailed it!! Thank you. :smiley:

You can make the trunk itself the container, and give it a lid, as a part of it, making the lid a supporter. Use something like–

A lid is a part of the trunk.  It is a supporter.  Understand "trunk/-- top/lid" as the lid.

Instead of putting something on the trunk:
    try putting the noun on the lid.

That way you have only two things to deal with (the trunk and the lid). Now you can say something like–

After opening the trunk:
    if there is something on the lid:
        say "The stuff you had on the top slides right off as the trunk creaks open.";
        now everything on the lid is in the location;
    otherwise:
        say "The trunk creaks open.  You're glad you didn't have anything sitting on it.  Whew!"

You would also write some other rules dealing with the top/lid, such as:

Instead of opening the lid:
    try opening the trunk.
Instead of closing the lid:
    try closing the trunk.

And dealing with the description–

A trunk is a container.  It is closed and openable.  The description is "Just your usual trunk[if the trunk is open].  It is yawning open[otherwise].  It is closed[end if][if there is something on the lid]; on top, you can see [a list of things which are on the lid][end if]."

The brackets within the description can carry if-then clauses, printing following text if the clause is true. Just make sure that you include an [end if] at the end of the options. The ‘[a list of things which are on the lid]’ will list everything that is on the lid.

Another tip–if the trunk is to be scenery, make sure you say similar things in the room description, like ‘In the middle of the room is a trunk, [if the trunk is open]its top yawning open[otherwise]which is closed[end if][if there is something on the lid]; on top of it, you can see [a list of things which are on the lid][end if].’ The After rule above will move anything from the lid to ‘the location’(= the floor of the room that you are in) which was previously on the lid, so you will have a ‘you-can-also-see’ message for these items when the player 'look’s.

If the trunk is not scenery, then you can type that brief description in an ‘initial appearance’ statement, right after you name the trunk–

A trunk is here.  It is a closed container.  It is openable.  "Lying in the middle of the floor...."  The description is "...."

I will leave you alone now. I know that this is a lot to take in, I remember feeling overwhelmed when I started writing my first IF. It’s been 5 years now and I am still learning! But I’ve never stopped having fun doing it! I hope you enjoy it as much as I do!

1 Like

Oh, I forgot to add–make sure that when the trunk is open, you disallow putting things on the lid–

Check putting something on the lid when the trunk is open:
    instead say "Hazardous, given that the trunk is open."
1 Like

Thank for the involuntary idea for a new solution for the age-old “dropping down the hole” puzzle… [Sadly there’s no “lighted lightbulb” emoji :angry: ]

Best regards from Italy,
dott. Piergiorgio.

1 Like