Common Commands Sidebar by Alice Grove


Chapter: Acknowledgements

Thanks to Joseph Geipel, Andrew Schultz, and Nick Turner for testing, to Björn Paulsen for code feedback, and to Björn Paulsen, Daniel Stelzer, Dannii Willis, Erik Temple, Hanon Ondricek, Joseph Geipel, Juhana, Matt Weiner, Peter Piers, and zarf for responding to my questions.

This extension is inspired by 'How To Play Interactive Fiction: An entire strategy guide on a single postcard' written by Andrew Plotkin and designed by Lea Albaugh. The postcard, available at <http://pr-if.org/doc/play-if-card/>, is licensed under a CC BY SA 3.0 United States license, available at <http://creativecommons.org/licenses/by-sa/3.0/us/>. Content from the postcard has been adapted with permission.

Modifications from the original postcard:

* Adapted to extension form with Inform code and documentation.
* Layout changed to vertical window.
* Changed colors.
* New heading.
* Condensed the list of commands and added extension-specific commands.
* Changes to wording, arrangement, and text formatting of commands.
* Explanations and other text omitted.
* Compass rose represented in text; other graphical elements omitted.

Chapter: Basics

Section: About the Required Extensions

Common Commands Sidebar requires

Version 15/161003 of Flexible Windows (for Glulx only) by Jon Ingold

http://raw.githubusercontent.com/i7/extensions/master/Jon%20Ingold/Flexible%20Windows.i7x

which in turn requires various other extensions that can be found at https://github.com/i7/extensions. See Flexible Windows for the version numbers required.

(Basic Screen Effects is also required, but any relatively recent version will do.)

Note that Flexible Windows uses the container relation for windows, so we'll need to be cautious about iterating through all containers. Also note that Spatterlight is liable to crash when Flexible Windows is used. If Common Commands Sidebar detects Spatterlight, the player will be warned to switch interpreters.

Section: Bare Minimum Implementation

If we want the default appearance and behavior for the sidebar, the only thing we need to do is to include the following line in our source:

Include Common Commands Sidebar by Alice Grove.

Everything else is optional.

Section: Toggling the Sidebar from a Full-Screen Menu

When we open a full-screen menu created with Menus by Emily Short or Menus by Wade Clarke, the sidebar, if visible, will be automatically hidden. It will also be flagged so that, once the menu closes, the sidebar will automatically be shown again. To allow toggling the sidebar from inside the menu, we can write a toggle rule to set the sidebar property

flagged to appear later

as in the "Lost in 'Lost Igpay'" example.

Chapter: Options

Section: Built-in Options

Many of the options can be set with a single rule, for example

When play begins:
     prepare the command sidebar, shown automatically, on the right, with italic type.

The first part of the rule


When play begins:
     prepare the command sidebar,

is followed by one or more of the phrases below, separated by commas. Within each of the following code blocks, phrases are mutually exclusive--including both "prompted automatically" and "shown automatically," for instance, will result in only one of these options taking effect. (See the section on debugging.)

The sidebar can be introduced in one of three ways:

prompted automatically
shown automatically
shown manually

"Prompted automatically," the default setting, prompts the player to choose whether or not to show the sidebar. "Shown automatically" displays the sidebar without giving the player a choice. "Shown manually" keeps the sidebar hidden until it is shown manually (for instance, if the player types SIDEBAR ON).

The "prompted automatically" and "shown automatically" options include a brief explanation of the sidebar. But if we choose "shown manually," it will be up to us to inform the player that the sidebar is available. We may want to give instructions in our help text for turning the sidebar on and off (SIDEBAR ON and SIDEBAR OFF), and for listing the commands in the main window (COMMANDS) if a player's interpreter or screenreader doesn't support the sidebar. See also the section on toggling the sidebar from a menu.

To position the sidebar (left is the default):

on the left
on the right

To choose a style for the sidebar text ("with roman type" is the default):

with roman type
with fixed letter spacing
with italic type
with bold type

To visually divide the groups of commands (the default is "divided with space," which leaves a blank line between categories):

divided with space
divided with stars
not divided

(Note: For a custom divider, we can instead set the variable "custom sidebar divider" to the ornament we'd like to use, altering the typeface from our other sidebar text if desired:

The custom sidebar divider is "[fixed letter spacing]+ + +[variable letter spacing]".

This is not part of the "prepare the command sidebar" line.)

To add, at the bottom of the sidebar, any additional commands that have been provided by compatible extensions (this option is off by default):

with extension commands

For example, a swimming extension might add a "Swim" command, and an invisibility extension might add a "Turn invisible" command. If the extension authors have made their extensions compatible with Common Commands Sidebar, and if we've included both these extensions in our source after Common Commands Sidebar, the "with extension commands" option will add the commands "Swim" and "Turn invisible" to the end of the sidebar, after a divider. (If we want to fine-tune the sequence of commands, we should skip this option and arrange them by hand instead. See the "cut and paste method" in the chapter on changing the text in the sidebar.)

To suggest to players who enter a blank command, and who do not have the sidebar visible, that they type SIDEBAR ON or COMMANDS to see some commands to try (this suggestion is disabled by default):

suggested after blank commands

To prevent the typed commands SIDEBAR ON, SIDEBAR OFF, and SIDEBAR (which normally turn the sidebar on and off) from being understood:

with toggling disabled

To leave the status line untouched, instead of automatically adjusting it when the sidebar is visible:

without changing the status line

This extension assumes we are using Inform's default status line, with the player's surroundings on the left and (if we are using scoring) the score and turn count on the right. To avoid inconsistent text alignment between the status line and the sidebar, and to avoid ambiguity (especially if the sidebar and status line are similar in color), this extension by default centers the standard status text whenever it would otherwise appear directly above the sidebar. If we have a custom status bar, we'll likely want to disable or adjust this behavior.

Section: Debugging

A built-in debugging feature will warn us if 'prepare the command sidebar' is invoked more than once in the code (in which case a later invocation will override an earlier one) or if mutually exclusive sidebar options have been chosen (in which case only one of the options will take effect). The debugging messages are disabled in the release version of the story. We can also turn off debugging in the not-for-release version by including

The sidebar is disabling debugging in the not-for-release version.

in our code.

Section: Colors, Margin, and Measurements

To change the sidebar colors from the default brown text on a beige background, we can use hex color codes (the 6-digit variety). A web search for "hex color codes" will bring up helpful sites that give the codes. For a black background with white text, we could say


The background color of the sidebar is "#000000".
The text color of the sidebar is "#ffffff".

Since not all interpreters support indentation, the left margin of the sidebar is created by printing fixed-width blank spaces at the beginning of each line. We can override this default indentation with our own, putting the desired number of spaces between the quotation marks:

The indent of the sidebar is " ".

To set the sidebar width (in characters, not pixels), we could say

The measurement of the sidebar is 28.

The units used to measure text windows vary in size from one interpreter to another--width in characters is an approximation. We'll want to check the results in interpreters that are used by players, because the sidebar may look very different in the Inform IDE.

To set the minimum size that we want the main window to be (in approximate characters, rather than pixels) in order to allow the sidebar to be displayed, we can say, for instance,


The minimum window width for opening of the sidebar is 60.
The minimum window height for opening of the sidebar is 20.

If, at the start of play, the main window does not meet these minimums, and if the sidebar is set to be shown automatically or to show an opening prompt, the player will instead see an opening message about how to list the commands in the main window.

Section: Colors, etc. in Quixe

The Quixe interpreter will not automatically display the colors we have set in the source. To customize the colors, presence/absence of scroll bars, and various other elements as they appear in the Quixe interpreter, we can "Release along with an interpreter" (see "25.11. A playable web page" in the Inform manual) and modify the glkote.css file found in the interpreter folder. Glkote.css is automatically generated on each release, so we'll want to keep a copy of the modified file where it won't be overwritten. (There's a bit about this in "25.13. Website templates" in the Inform manual.)

The glkote.css file is written in a language called CSS. In glkote.css we should use ".WindowRock_225" to identify the sidebar.

An example: to set the sidebar's background color ("background") to light blue and its text color ("color") to dark blue using hex color codes, we could add the following to the CSS file. (Despite how the spacing may appear in this documentation, there should be no space between the period and the W.)

. WindowRock_225 {
background: #BAF7F4;
color: #070833;
}

More information about CSS is available with a web search. There are also some explanatory comments in the glkote.css file, available in the interpreter folder, as mentioned, or at <http://github.com/erkyrath/quixe/blob/master/media/i7-glkote.css>. Further information can be found at <http://eblong.com/zarf/glk/glkote/docs.html#css>.

Chapter: Using Different Commands in the Sidebar

If we don't want to use the default set of commands in the sidebar, there are several ways we can go about adjusting the commands. We can paste in and edit a provided template with the "Cut and Paste" method, or alter the default table using code with the "Add or Remove Rows in the Default Table" method, or swap entire sets of commands in and out during play with the "Swap in a Different Table" method.

Note that when we tailor the commands in the sidebar, we are also affecting the list printed by the "listing the sidebar commands in the main window" action. After we've made changes to the sidebar commands, we should type COMMANDS to see how they look in list form. See also "Adjusting the Commands Listed in the Main Window."

Section: The "Cut and Paste" Method

The "Cut and Paste" method of tailoring the sidebar commands gives the most control for the least effort. If we paste one of the templates below into our code to continue the (initially blank) Table of Custom Sidebar Commands, we can edit, cut, and paste rows to arrange the commands exactly how we want them. What you see is basically what you get. If we continue the Table of Custom Sidebar Commands in our code, our custom table will automatically be substituted for the default table in the sidebar (unless we specify otherwise).

The commands in this first template are identical to the commands in the default sidebar:


Table of Custom Sidebar Commands (continued)
Displayed Command
"[bold type]Useful Commands"
" "
"[fixed letter spacing] N"
"[fixed letter spacing] NW NE"
"[fixed letter spacing]W * E"
"[fixed letter spacing] SW SE"
"[fixed letter spacing] S"
" "
"In/Out"
"Up (U)/Down (D)"
"?"
"Look (L)"
"Inventory (I)"
"Take/Drop something"
"Examine (X) it"
"Open/Close it"
"Push/Pull it"
"Put it in something"
"Put it on something"
"Wait (Z)"
"?"
"About"
"Help"
"Hint"
"Again (G)"
"Undo"
"Save/Restore"
"Quit (Q)"
"[if the sidebar is allowing toggling]Sidebar on/off[end if]"

This next template has the above commands plus Give, Show, Ask, and Tell, for stories with other characters:


Table of Custom Sidebar Commands (continued)
Displayed Command
"[bold type]Useful Commands"
" "
"[fixed letter spacing] N"
"[fixed letter spacing] NW NE"
"[fixed letter spacing]W * E"
"[fixed letter spacing] SW SE"
"[fixed letter spacing] S"
" "
"In/Out"
"Up (U)/Down (D)"
"?"
"Look (L)"
"Inventory (I)"
"Take/Drop something"
"Examine (X) it"
"Open/Close it"
"Push/Pull it"
"Put it in something"
"Put it on something"
"Give it to someone"
"Show it to someone"
"Ask someone about it"
"Tell someone about it"
"Wait (Z)"
"?"
"About"
"Help"
"Hint"
"Again (G)"
"Undo"
"Save/Restore"
"Quit (Q)"
"[if the sidebar is allowing toggling]Sidebar on/off[end if]"

If we'd rather start from scratch, we can use a table continuation with the following name and column heading:


Table of Custom Sidebar Commands (continued)
Displayed Command (a text)

Below this, we list the sidebar title (if desired) and command entries in a single column in the order we'd like them displayed. Each "?" entry will automatically be replaced with the chosen divider option (which, if it's a text ornament, will include a blank line before and after). A blank line will automatically be added at the top of the sidebar. Each " " entry will result in a blank line in the sidebar. (That's a single space between quotation marks--using more than one space can lead to stray punctuation in the auto-generated list for the "listing the sidebar commands" action.)

Section: The "Add or Remove Rows in the Default Table" Method

If we'd rather write traditional code than paste in a template, we can use code to add or remove rows in the Table of Default Sidebar Commands, which is found in the extension source. Or we could continue this table to add new commands at the end, perhaps starting with a divider ("?") if we want to separate the new commands from the default meta commands:


Table of Default Sidebar Commands (continued)
Displayed Command
"?"
"New Command 1"
"New Command 2"

For more information, see "16.9. Blank rows," "16.10: Adding and removing rows," and "16.18: Table continuations" in the Inform manual.

Section: The "Swap in a Different Table" Method

Still another approach to adjusting the commands in the sidebar is to designate a specific table (an additional table we have created, or one from an extension) as the table from which the sidebar commands should be drawn. To do this we use the phrase "swap Table Name into the/-- sidebar":


When play begins:
     swap the Table of Aquatic Commands into the sidebar.

We can swap in any table so long as it includes a column with the following heading:


Displayed Command (a text)

If we don't include this column, the commands will not show up in the sidebar.

The "swap Table Name into the/-- sidebar" phrase can also be used to switch from one set of commands to another mid-story.

Chapter: Adjusting the Commands Listed in the Main Window

When the player types COMMANDS, the "listing the sidebar commands in the main window" action prints the sidebar commands in the main window. This feature is intended for players using screenreader software, or devices with small screens, or interpreters that won't display the sidebar (e.g. Parchment).

The list is automatically generated from our table of commands, so we'll probably want to check that the results look reasonable, especially if we've changed the sidebar text or if we're controlling command visibility with phrases.

If we want to adjust the results, and if the commands will not change during play, we can create our own list as a string called the "custom command list of the sidebar", for instance


The custom command list of the sidebar is "Useful Commands. North (N). South (S). East (E). West (W). Talk to someone. Help. Quit (Q)."

Our custom list will automatically be used instead of the auto-generated list.

If we instead want to modify listed commands individually (for instance, if we're using phrases to show or hide commands during play, and so the list needs to change during play), we can use the column "Listed Command" in our command table to show how we want each command to appear in the list. When the commands are printed as a list in the main window, the Listed Command entry, if present, will automatically be printed instead of the Displayed Command entry. Each entry will be followed by a period when it's printed in the list, but if we need additional periods within an entry, we'll need to include those ourselves, as in the "West (W). East (E)" entry below.

Displayed Command Listed Command
" N" "North (N)"
"W E" "West (W). East (E)"
" S" "South (S)"
"In (I)/Out (O)" --

The commands in the above table will look like ths in listed form:

North (N). West (W). East (E). South (S). In (I)/Out (O).

Chapter: Showing and Hiding Individual Commands During Play

If we want to hide or show individual commands during play, we can use conditions or phrases. Either way, we'll want to make sure to update the sidebar.

Section: Updating the Sidebar During Play

If the contents of the sidebar change during play, we can use the phrase "refresh the sidebar" inside a rule to keep the sidebar up to date, for instance:


Every turn:
     refresh the sidebar.

Note that if we refresh often, we'll want to be extra careful about whether our sidebar commands fit into the height of the window. If the list of commands is too long to fit in the window, an interpreter may show a "More" message at the bottom of the sidebar and require the player to press a key before continuing. This will happen every time the sidebar refreshes. To avoid making the player press an extra key every turn, we'll want to make sure our list of commands isn't overlong, and set the minimum window height to an adequate number. (See the "measurements" section.)

Section: Showing and Hiding Using Conditions

We can include conditions in the text of the displayed command entries to specify when to show them.

For example:

Displayed Command (a text)
"[if the player wears the duck costume]Quack[end if]"

If we do this in such a way that the entry evaluates to "" when the command is hidden, subsequent commands in the sidebar will move up to close the gap.

But if we want a blank line in the sidebar where the absent command belongs, we should instead arrange for the entry to evaluate to " ". (That's a single space. Using more than one space may lead to extra punctuation in the "listing the sidebar commands" action.)

For example:

Displayed Command (a text)
"[if the player wears the duck costume]Quack[end if] "

For more complicated conditions, we can make the table more readable by putting the conditions in "to decide" phrases outside of the table:

To decide if quack is displayed:
     if the player wears the duck costume, decide yes;
     if the player is a duck, decide yes;
     decide no.

Displayed Command (a text)
"[if quack is displayed]Quack[end if]"

For more on "to decide" phrases, see "11.16. New conditions, new adjectives" in the Inform 7 manual.

Section: Showing and Hiding Using Phrases

If we want to use phrases to show or hide commands, we need to opt in by including the following line in our code:


The sidebar is using phrases to control command visibility.

We also need to declare a "command-label" for each command or group of commands that we want to show or hide during play. For instance:

turn_invisible is a command-label.
compass_direction is a command-label.

In our table of commands, we include the columns "Command Label" and "Command Visibility":


Displayed Command (a text) Command Label (a command-label) Command Visibility (a command-visibility)

In the "Command Label" column, we enter the command-label we want to use for the command in that row. If we have multiple commands that we want to treat as a single unit for showing and hiding purposes, we can list the same command-label in all the relevant rows.

In the Command Visibility column, we can enter one of these options in each row:

c-shown
c-blank
c-hidden

"C-shown" means the relevant command entry is displayed normally. "C-blank" means the relevant command entry is not visible, but a blank line appears in the sidebar where the command belongs. "C-hidden" means the relevant command entry is not visible, and subsequent commands in the sidebar are moved up to close the gap.

Strictly speaking, we need only specify "c-blank" and "c-hidden," because any entries missing from the Command Visibility column will be treated as "c-shown".

An example:


Displayed Command (a text) Command Label (a command-label) Command Visibility (a command-visibility)
"North (N)" compass_direction c-blank
"South (S)" compass_direction c-blank
"East (E)" compass_direction c-blank
"West (W)" compass_direction c-blank
"Quack" quack c-hidden
"Turn invisible" turn_invisible c-shown

To show, hide, or blank (that is, leave a blank space for the command in the sidebar) commands during play, we can use the following phrases, where X is the command-label:


show the/-- X command/commands in Table Name
show the/-- X command/commands
hide the/-- X command/commands in Table Name
hide the/-- X command/commands
blank the/-- X command/commands in Table Name
blank the/-- X command/commands

The above phrases will show, hide, or blank all instances of X in the given table. The choices "command" and "commands" are provided only so that the code can read naturally regardless of whether the command-label applies to one command, or several.

If we don't mention the table name, the extension will look for X in whichever table is currently designated as the source of sidebar commands. (That table name is held in the property "chosen table of the sidebar").

If we are trying to show, hide, or blank a command, and the command-label is not found in the table, the attempt will either generate a debug message (if debugging is on) or be ignored (if debugging is off).

Some examples:

After wearing the duck costume:
     show the quack command in the Table of Special Commands;
     continue the action.

After taking the ancient compass:
     show the compass_direction commands;
     continue the action.

To find the Command Visibility entry for for a given command label, we can use the following phrases, where C is the command-label:

the/-- command-visibility of C in Table Name
the/-- command-visibility of C

These will check only the first instance of C in the table. And if we don't mention a table name, the extension will assume we mean the "chosen table of the sidebar."

If there a Command Visibility column but no Command Visibility entry in the given row, the command is treated as shown, and so these phrases will return the value "c-shown".

But if there's something wrong with the table (for instance, if the command-label is not found in the given table), these phrases will return the value "c-table-error". If debugging is on, a debug message will be shown.

Chapter: A Note to Extension Authors

If we've written an extension that creates a new command for the player, we can, in a section marked "(for use with Common Commands Sidebar by Alice Grove)," include the following table continuation:


Table of Extension-Provided Sidebar Commands (continued)
Displayed Command
"New command goes here"

By using this table, we make our extension compatible with other extensions adding their own sidebar commands. This way the story author can automatically add commands to the sidebar from multiple extensions at once, just by adding "with extension commands" to the "prepare the commands sidebar" line.

If we want to provide a complete list of commands that can replace the default commands (for instance, if we're translating Common Commands Sidebar into another language), we can write a new extension to be used in place of Common Commands Sidebar, or we can write a compatible extension that provides a new table with a unique name. In the new table, the commands should be listed in a column entitled "Displayed Command (a text)". The story author can then swap in the new table if desired.

Most of the responses visible to players can be changed according to "14.11. Changing the text of responses" in the Inform manual, but there are two exceptions: the responses shown when players mistakenly type "sidebar [text]" or "commands [text]." These can be changed as follows:


The SIDEBAR instructions of the sidebar are "New response here.".
The COMMANDS instructions of the sidebar are "New response here.".

Extensions intended to be compatible with Common Commands Sidebar should not modify the Table of Default Sidebar Commands or the Table of Custom Sidebar Commands, as this would create obstacles for story authors who want to include only the original commands, or who want to create a custom list from scratch. Compatible extensions should also avoid setting any of the built-in sidebar options without good reason, because if both the extension author and the story author include "Prepare the Commands Sidebar" lines, the extension will detect both lines and generate error messages.

Example: * The Absolute Minimum - Including the sidebar with a minimum of code.

"The Absolute Minimum"

Include Common Commands Sidebar by Alice Grove.

Minimal Room is a room.

Test me with "sidebar / sidebar / sidebar off / sidebar on / commands".

Example: * Sidebar in Chocolate - A sidebar that makes use of presentation options and a custom command list.

Here we have an automatically-shown sidebar with a brown background, italic off-white text, plus signs as dividers, and a custom list of commands.

"Sidebar in Chocolate"

Include Common Commands Sidebar by Alice Grove.

Table of Custom Sidebar Commands (continued)
Displayed Command (a text)
"[bold type]Common Commands"
" "
"About"
"Help"
"Hint"
"Again (G)"
"Undo"
"Save/Restore"
"Quit (Q)"
"?"
"Look (L)"
"Inventory (I)"
"Take/Drop something"
"Examine it (X it)"
"Open/Close it"
"Push/Pull it"
"Put it in something"
"Put it on something"
"Wait (Z)"
"?"
"Give it to someone"
"Show it to someone"
"Ask someone about it"
"Tell someone about it"

The background color of the sidebar is "#542c03".
The text color of the sidebar is "#faf0e6".
The custom divider of the sidebar is "+ + +".

When play begins:
     prepare the command sidebar, shown automatically, with italic type.

Help Desk is a room.

A supporter called the desk is in Help Desk.

Test me with "sidebar / sidebar / sidebar off / sidebar on / commands".

Example: * Lost in 'Lost Igpay' - A way to toggle the command sidebar from inside a full-screen menu using Emily Short's Menus extension.

"Lost in 'Lost Igpay'"

Include Menus by Emily Short.
Include Common Commands Sidebar by Alice Grove.

Asking for help is an action out of world.
Understand "help" and "elphay" as asking for help.

Carry out asking for help:
     now the current menu is the Table of Options;
     carry out the displaying activity;
     clear the screen;
     try looking.

Table of Options
title     subtable (table name)     description     toggle (a rule)
"How to Play"     --     "[How_to_Play]"     --
"Commands Sidebar (currently [if the sidebar is not flagged to appear later]off[otherwise]on[end if])"     --     --     toggle sidebar from menu rule

To say How_to_Play:
     say "Help Unkgray find the lost igpay! At the prompt ( > ), type short commands to tell him what to do.[paragraph break]To see a sidebar that lists the most common commands, toggle the COMMANDS SIDEBAR option on the top level of this menu. You can also type COMMANDS to list these commands in the main window.".

This is the toggle sidebar from menu rule:
     if the sidebar is not flagged to appear later:
         now the sidebar is flagged to appear later;
     otherwise if the sidebar is flagged to appear later:
         now the sidebar is not flagged to appear later.

When play begins:
prepare the commands sidebar, shown manually;
say "For two weeks you resisted the inevitable. But Gretchen's enthusiasm was unrelenting.[paragraph break]'All right,' you finally said. 'Show me this text adventure you've been telling me about.'[paragraph break]So here you are, scowling at some game called 'Lost Igpay.' And that's exactly what you are: lost. You've tried typing 'Start looking for the igpay' and 'Go find the igpay!' and 'Unkgray need find igpay now' and nothing seems to work.";
wait for any key.

At the Computer is a room. The description of At the Computer is "The screen is strewn with failures of communication."

Gretchen is a woman in At the Computer. "Gretchen stands at your shoulder, clasping her hands in gleeful anticipation.[first time][paragraph break]'Don't worry!' she says. 'There's a helpful sidebar that shows all the common commands! Type HELP to go to the menu. You can turn on the sidebar from there!'[only]".

Test me with "help".

Example: *** Dropping the Compass - Using phrases to blank out compass directions in the sidebar when the player drops the compass.

"Dropping the Compass"

Include Common Commands Sidebar by Alice Grove.

compass_direction is a command-label.

Table of Custom Sidebar Commands (continued)
Displayed Command     Command Label (a command-label)     Command visibility (a command-visibility)
"[bold type]Useful Commands"     --     --
" "     --     --
"[fixed letter spacing] N"     compass_direction     c-shown
"[fixed letter spacing] NW NE"     compass_direction     c-shown
"[fixed letter spacing]W * E"     compass_direction     c-shown
"[fixed letter spacing] SW SE"     compass_direction     c-shown
"[fixed letter spacing] S"     compass_direction     c-shown
" "
"Look (L)"
"Inventory (I)"
"Take/Drop something"
"Examine (X) it"
"Quit (Q)"

Shifting Cavern is a room. "Your usually excellect sense of direction fails you in this strange cavern. You feel vaguely dizzy."

A compass is a thing. The description of the compass is "They insisted that you bring it."

The player carries the compass.

When play begins:
     prepare the command sidebar, shown automatically.

The sidebar is using phrases to control command visibility.

Every turn:
     refresh the sidebar.

Every turn when the turn count is 1:
     now the compass is in the location of the player;
     blank the compass_direction commands;
     say "Gravity shifts in the cave, sweeping the compass out of your grip. The instrument meanders sideways through the air, then loops overhead before crashing to the ground.[paragraph break]You no longer know which way is which."

Instead of going a direction when the player does not carry the compass:
     say "Without the compass you have no idea which way is which."

After taking the compass:
     show the compass_direction commands;
     say "Phew! Now you can orient yourself."

After dropping the compass:
     blank the compass_direction commands;
     say "You drop the compass...and now you don't know which way is which."

Test me with "commands / inventory / x compass / commands".