Title Case For Headings by Nathanael Nerode
Version 2.0.220529
Applies title case to room names printed as a heading or in the status line. Creates the printing a heading activity for further customization. Tested with Inform 10.1.0. Requires Undo Output Control by Nathanael Nerode to handle the case of room name printing after UNDO.
Section 1: The Problem
Section 2: The Solution
Section 3: Advanced Solution - the printing a heading activity
Section 4: Making it work right with "Undo" - Include Undo Output Control
Section 5: Changelog
Examples
A — Meadow
B — The Meadow
C — Around the Pond
D — People's Rooms
Section 1: The Problem
It is traditional to give rooms titlecased names, like "The Meadow". However, it is also often desirable to put a room into scope. This may be done so that people can say "look at the meadow", or so that people can look at faraway rooms. When the room is in scope, or for other reasons, the room name may be printed in various other contexts, including some of the responses in the Standard Rules. And often we don't want those to be titlecase.
For instance, if you try this, the title in the status line and room description heading will be "Meadow"; but 'take meadow' will print "You would have to get out of the Meadow first."
"Too Much Uppercase"
The Meadow is a room. "This is a meadow."
After deciding the scope of an object (called character):
Place the location of the character in scope, but not its contents.
And if you try this, 'take meadow' will print "You would have to get out of the meadow first", but the title in the status line and room description heading will be "meadow".
"too much lowercase"
a meadow is a room. "This is a meadow."
After deciding the scope of an object (called character):
Place the location of the character in scope, but not its contents.
test case with "take meadow / look"
When you start having rooms with possessive names like "John's Hotel Room", it gets even more complicated. You probably want it to be called "the hotel room" in text but "John's Hotel Room" in the status line and headings.
Section 2: The Solution
This extension will convert names like "babbling brook" to "Babbling Brook" (or "box" to "Box", etc.) for the heading at the top of the room description, and for the status line, but otherwise keep them in lowercase. So we will see:
Babbling Brook
This is a location.
> take brook
You would have to get out of the babbling brook first.
The example Meadow does this.
In addition, if a room or other object has the property "title", that will be used for the headings instead. The type "titled room" is provided as a kind of room with a "title" property, but you can also give other kinds a "title" property if you want to.
The examples The Meadow and Near the Pond do this.
Section 3: Advanced Solution - the printing a heading activity
This extension also introduces the "printing a heading" activity.
Printing a heading is active when printing the room name at the top of a room description. It is not active when printing the name of a dark room, which has its own "printing the name of a dark room" activity.
Printing a heading is also active when printing the name of a thing at the top of the visibility threshold. For instance, if you're inside a closed opaque box, the heading should read:
Box But it is not active when printing the name of a container which is not at the top level, so that you will get:
Green Room (in the box)
Printing a heading is also active when printing a name for the status line. (This does not normally have parenthetical expressions on it so I did not special-case them.)
By default, printing a heading will apply title case to the printed name of the object (See "Meadow".) If the object has a "title" property, it will instead print that. (See "The Meadow" and "Near the Pond".) But it can be overridden to print whatever you want.
The example "People's Rooms" implements a complex naming scheme involving possessives, which change depending on who the player character is.
Section 4: Making it work right with "Undo" - Include Undo Output Control
There is one annoying corner case. When "undo" is successfully executed, the room name is printed as a heading. For this extension to process this heading correctly, it is necessary to:
Include Undo Output Control by Nathanael Nerode.
The newest version of Undo Output Control is on the "Friends of I7" extension page on Github. I updated it specifically so that I could fix this bug. If you have trouble including Undo Output Control, you may just be willing to live with the bug.
Section 5: Changelog
2.0.220529: Remove documentation section numbers to allow for automated numbering
2.0.220527: Revise examples to work with automated testing of examples
2.0.220524: Reformat Changelog
2.0.220522: Correct a version number SNAFU
1.2.220522: Example bugfix, remove unnecessary dummy variable, add Changelog
1.2.220521: Proper update to Inform v10
1.2: Partial update to Inform v10
1/170902: Version for inform 6M62
Section 6 - Examples
|
Example Meadow The title is Meadow, the name is meadow |
|
Example The Meadow But we want the title to be *The* Meadow. |
|
Example Around the Pond A more complex example |
|
Example People's Rooms Rooms with possessive names |
This example lets you play the game as John or Alice, using an initial Pick Identity scene. After picking an identity at the start of the game, the default "yourself" object is removed. The text substitutions adjust the printed names and titles of the dorm rooms to match (so one of them is "Your Dorm Room" and the other is "Alice's Dorm Room" or "John's Dorm Room". There is one really tricky bit. The Standard Rules will not list an item in the room description if it believes the item has been mentioned already. Using the possessive form of John in the title of the room causes it to be marked as mentioned, so it must be unmentioned before the room description is printed -- or else John will turn invisible when in his own room. In the Pick Identity scene, it is necessary to run the scene checking rules manually to trigger the scene change at the right time. The initial room description must be deferred until after the identity is chosen, as well. Note the careful attention to capitalization in the descriptions. The title case in the headings, however, happens automatically. Test this by looking at all the rooms as John, and then by looking at all the rooms as Alice. "People's Rooms" The story author is "Nathanael Nerode". To say unmention (item - a thing): Pick Identity is a scene. When Pick Identity begins: The initial room description rule is not listed in the startup rulebook. After reading a command when Pick Identity is happening: When Pick Identity ends: To say (T - a text) capitalized/capitalised: To say (O - an object) capitalized/capitalised: Dormitory Hallway is a room. "This is the hallway of the dormitory. [Dorm room 1 capitalized] is to the west and [dorm room 2] is to the east." A dorm room is a kind of room. Rule for printing the name of a dorm room (called item) while printing a heading: Dorm room 1 is a dorm room. Dorm room 2 is a dorm room. John is a man. Alice is a woman. |