[I6] Scenery containers

A cupboard is scenery. How can I have an individual description, but standard output regarding its status and contents? Like,

This is my cupboard description.
The cupboard is closed.

or

This is my cupboard description.
Inside the cupboard is an object.

Do I have to program that myself, or is there library support? If there’s no support, how do I print out all contents of the cupboard?

My problem is that the output is always “This is my cupboard description.”, no matter if the cupboard is closed, open but empty or open and containing something.

May I ask for help again? My desired target output is -

x cupboard
A cupboard.
open cupboard
You open the cupboard, revealing an item.
x cupboard
A cupboard. It contains an item.

But what I currently have is -

x cupboard
A cupboard.
open cupboard
You open the cupboard, revealing an item.
x cupboard
A cupboard.

How can I get the open cupboard to show what’s inside, without these items being shown while the cupboard is closed?

Read S27 of the DM4, “Listing and grouping objects”. Then you can have your description routine make use of WriteListFrom.

Or, you could have your description routine call L__M(##Search, 7, cupboard). But still, you should get to know the listmaker because it’s very useful.

Almost works as intended, thanks! Except, there’s a weird “1” at the end (“The cupboard contains an item1.”). Also happens with a tall inventory:
The cupboard contains:
an item
1.
Any idea where that’s coming from?

Your code should say

L__M(##Search, 7, cupboard);

and not

print L__M(##Search, 7, cupboard);

This is explained in the Designer’s Manual.

That happens because something in your code is returning true, and true is the same as 1, so a 1 is printed. I forget how to work around it, but it’s a well-known and trivial I6 issue.

While I didn’t find any clues on how L__M works in the manual, it works, and for the future I know what to do. Thanks Egon and everyone else!

The Designer’s Manual was surprisingly silent on the matter.
However, L__M calls the LanguageLM routine which runs the library message for the choosen action. Those messages are already print_ret statements, so they end with an rtrue. If you print (rather than simply run) a print_ret statement, you will print the return value too (as Jim Aikin explained).

More fundamentally, you should never print a function call.