How to show inventory in sidebar

In tads 3 game not web. I have sidebar i can add pic no trouble. However i would like to have my inventory showing at all times, can this be done?

You can capture text output and redirect it to a banner. Add a function to your banner that does this (showInventory() in this example.) Calling showInventory() will clear the banner and display the inventory.

Obviously you need to call that function every time the inventory changes. Trying to hook into the various functions when objects are added or removed might be overkill here. You can simply call it unconditionally after every input with a PromptDaemon.

inventoryBanner: CustomBannerWindow {
    bannerArgs = [
        nil, BannerAfter, statuslineBanner, BannerTypeText, BannerAlignTop, 10,
        BannerSizeAbsolute, BannerStyleBorder

    promptDaemon = static new PromptDaemon(self, &showInventory);
        captureOutput({: gActor.showInventory(inventoryMode == InventoryTall) });

The argument passed to captureOutput() must be a callable function. It will be called by captureOutput() and any output it produces will be redirected to the banner. In this case, we pass an short-form anonymous function (that what the {: syntax is):

{: gActor.showInventory(inventoryMode == InventoryTall) }

So captureOutput() will call that anonymous function, which in turn will call gActor.showInventory().

(In many other programming languages, these are called “lambda expressions”.)

More info here:

Oh, btw, the above example just assumed you’re using the customBanner extension (lib/extensions/customBanner.t). If not, just adapt accordingly, of course. The exact same approach of using captureOutput() and a PromptDaemon should work regardless.


I just finished implementing a window like this in my own project. I used virtually the exact technique described by RealNC with captureOutput and a PromptDaemon. However, I wanted my inventory window to look a little different from the normal Tall display. To keep a low profile I used ‘name’ instead of ‘aName’, and eliminated the ‘which contains:’ prefixes, and simply indented anything that is contained two spaces. My method is probably a hack, but I created a second custom inventory lister on the player character in a separate property. Then the inventoryWindow promptDaemon changes the player character’s inventory lister before displaying to the banner, and changes the lister back to normal once it has displayed. My window looks something like this: (The tildes do not appear in the game, they should be just empty spaces… but I tried using just space characters on this website and it shifted everything to align left…)


toy car
~ spoon
~ fork
glass jar
~ locket
~~ snippet of hair
~ pebble
pair of slippers

1 Like

One thing to keep in mind when doing changes like this where it’s really important that they get undone afterwards, is to guard against exceptions that would result in the change not getting reverted. The pattern to follow is that instead of:


you should do:

try {
finally {

That way if any of the other stuff happens to throw an error, the change will still be undone (the finally block will be executed regardless of whether an exception was thrown or not.)



Good idea… I’m still new to this programming stuff!