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.
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?
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.
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).