How can I show contents in the inventory?

With the current library, taking inventory doesn’t show the contents of items. (For example, if you’re carrying a bottle containing a quantity of water, the bottle appears in the inventory listing, and the water doesn’t.)

Is there any way to change this? The list-writer doesn’t seem to have any way to recursively list contents, and putting the contents into the (name $) of the container seems like a very bad idea (for disambiguation if nothing else).

1 Like

Here’s one way:

(perform [inventory])
        (current player $Player)
        (if) ($ is #heldby $Player) (then)
                You have: (line)
                (list objects #heldby $Player indented 4)
        (else)
                You don't have anything.
        (endif)

(list objects $Rel $Loc indented $I)
        ($I plus 4 into $NextI)
        (exhaust) {
                *($Obj is $Rel $Loc)
                (space $I) (a $Obj) (line)
                (list objects $ $Obj indented $NextI)
        }
3 Likes