Inventory Listing Tall (adv3Lite)

The game I’m working on has a LOT of inventory the player can cart around. Much of it is in a BagOfHolding. I think it would be a courtesy to the player to offer the option of printing the list of stuff in a “tall” format (a vertical list). Inform does this very nicely, but I don’t see a way to do it in adv3Lite, other than by manually rewriting the inventoryLister … and that’s above my pay grade.

I could have a go at modifying adv3 code, as I doubt the listers are all that much different. adv3 already has a list setup for tall inventory listings, but I’m not at all sure how to analyze what’s going on in it. Can anyone offer any pointers?

1 Like

I’ll take a look at that later, if no one has jumped in first…

I definitely use the tall in my game…

Sorry Jim, I got sick over the weekend. Any progress with your lister? I don’t think you could use adv3’s tall lister unless you modified a lot of lines in lister.t… but I can’t be certain since I haven’t yet spent any amount of time looking at how Lite handles listing…

I’ve been meaning to add tall inventory listings to my adv3Lite-based WIP, and banged out this tonight:

modify gameMain
  /** Global switch for enabling tall inventory listings. */
  useTallInventory = nil
;

/**
 * Customize ItemLister to support tall listings.
 */
modify ItemLister
  /** Enable tall listings. */
  useTall = nil

  showList(lst, pl, paraCnt) {
    if (useTall)
      showTallList(lst, pl, paraCnt);
    else
      inherited(lst, pl, paraCnt);
  }

  showTallList(lst, pl, paraCnt) {
    "<br>\t<<lst.mapAll({ o: listName(o) }).join('<br>\t')>><br><br>";
  }
;

/**
 * Customize inventoryLister for tall listings.
 */
modify inventoryLister
  useTall = (gameMain.useTallInventory)

  showListPrefix(lst, pl, paraCnt) {
    if (!useTall)
      inherited(lst, pl, paraCnt);
    else if (paraCnt == 0)
      "{I} {am} carrying ";
    else
      "and carrying ";
  }

  showListSuffix(lst, pl, paraCnt) {
    if (!useTall)
      inherited(lst, pl, paraCnt);
  }
;

/**
 * Customize wornLister for tall listings.
 */
modify wornLister
  useTall = (gameMain.useTallInventory)
;

…then, in your game’s gameMain, set useTallInventory = true.

Note that this doesn’t perform a tall listing within a tall listing. In other words, if the player is carrying a container with items in it, the top-level inventory is tall but the sub-contents are not:

You are wearing 
	a T-shirt

and carrying
	a stick of gum
	a rubber ball
	a lunch box (in which are a sandwich and a Thermos)

Embedded tall listings could be done, but it would require adding tabs depending on how deep the listing has gone. I’m happy with the above presentation, though, especially since my game doesn’t have deep containers in the player’s inventory.

The formatting could be tweaked in other ways too, depending on what you’re looking for, but the above is a start.

2 Likes

Thanks! It works! In the game I’m working on, there can be about 20 things in the shopping bag, so it would be useful to have nested (embedded) listings. Here’s an example:

>i
You are wearing 
	some clothing

and carrying 
	a shiny aluminum key
	an Easter egg
	a little toy top
	a shopping bag (in which are a u-shaped piece of metal, a matchbook, an old-fashioned
army helmet, a golf ball, a cigar, a scarf, a big square perfume bottle, a cell phone, a crumpled
note, a bottle of nail polish, a battered trumpet, a shiny round key, a silver nightingale, an oil
can, a screwdriver, and a feathered dart)
	your purse (in which are a wallet and a car key)

In the game interpreter, of course, that humongously long line is wrapped around, so let’s see. I’ll approximate that. This is not necessarily bad, but I’m going to think about how to customize it further.

As a footnote, neither your code nor the default library lists the contents of an open container that’s inside another open container. This is not a fatal problem, but it’s not ideal.

a QoL refinement could be having the BagOfHolding listed last ?

or even, as a separate listing, like:


>i
You are wearing 
	some clothing

and carrying 
	a shiny aluminum key
	an Easter egg
	a little toy top
        your purse (in which are a wallet and a car key)

Inside your shopping bag are: 
a u-shaped piece of metal, a matchbook, an old-fashioned army helmet, a golf ball, a cigar, a scarf, a big square perfume bottle, a cell phone, a crumpled note, a bottle of nail polish, a battered trumpet, a shiny round key, a silver nightingale, an oil can, a screwdriver, and a feathered dart

seems a better presentation for a player, or I’m wrong ?

Best regards from Italy,
dott. Piergiorgio.

That’s a good idea. It would require modifications deeper in the library. Overriding Inventory.execAction() most likely, but I’m just eyeballing it. Right now, that function splits up the inventory into items worn and items carried. I think it would need to be altered to skip the BoH in “items carried” and present its contents last.

Another refinement I’ve done in my code is to use HTML unordered lists (<ul><li>...</li></ul>) when the interpreter supports them. The nice side-effect is that if a container’s contents run past the end of line, the next line is properly indented. I didn’t include this in the above because that’s a bit more involved, and the code I use relies on other helper functions in my internal library.

The upcoming version 1.6 contains my attempt at an INVENTORY TALL listing, which appears to do the job (Jim Aikin reports that he has used the pre-release code for this without any obvious problems, apart from one with listing the contents of closed containers, which I subsequently fixed).

2 Likes