Chapter 3: Things (3.1-3.7)
Chapter 3 let’s gooooooo!!!
Okay, so here I think we’ll get into actual game coding.
Appropriately, the very first example of real game code in this chapter is drawn from a port of Adventure (and the inform port of adventure is one of my favorite games of all time):
The Cobble Crawl is a room. "You are crawling over cobbles in a low passage. There is a dim light at the east end of the passage."
A wicker cage is here. "There is a small wicker cage discarded nearby."
The Debris Room is west of the Crawl. "You are in a debris room filled with stuff washed in from the surface. A low wide passage with cobbles becomes plugged with mud and debris here, but an awkward canyon leads upward and west. A note on the wall says, 'Magic word XYZZY'."
The black rod is here. "A three foot black rod with a rusty star on one end lies nearby."
Above the Debris Room is the Sloping E/W Canyon. West of the Canyon is the Orange River Chamber.
(I actually tried running this through a Borogove snippet but it said it took too long to respond, so my computer must be wonky again).
This is a perfect example to start off with because it shows how powerful Inform is for beginners and how hard it is to master for experts.
It’s good for beginners because it automatically makes rooms with two-way connections, objects that can be understood with both the adjective part and noun part independently, objects with a special message about them before they are picked up and a standard message after they are dropped again, etc.
So it makes an adequate game really easily. But not a GREAT game. Why not?
If we play this story, we find that we can type TAKE CAGE or TAKE WICKER CAGE, for instance, but not TAKE SMALL CAGE. Inform saw that we called this “a wicker cage” when it first appeared in the source text, and assumed that the player would call it that, too. (Whereas it didn’t look inside the descriptive text to allow for TAKE SMALL CAGE or TAKE DISCARDED CAGE or TAKE NEARBY CAGE.)
So a ton of IF programming is about this part here: making objects do everything they claim to do in the description, and adding all the synonyms.
I think the most synonyms I have for one thing in my current game is a haunted house:
The scenery-mansion is scenery in the front-room. The printed name of the scenery-mansion is "mansion". Understand "gorgeous" or "well-preserved" or "well" or "tidy-looking" or "tidy" or "asymmetrical" or "haunted" or "house" or "looking" or "house" or "mansion" or "queen" or "anne" or "preserved" or "victorian" or "tall" or "stately" or "handsome" or "old" or "parlor" as the scenery-mansion. The description of the scenery-mansion is "This is a tall and stately old Victorian mansion in the Queen Anne style. It is asymmetrical, with a tower on one side and some steps leading up to a tall wooden door on the other."
Back in Section 3.1, he points out:
A small limitation here is that probably only the first 9 letters of each word are read from the player’s command. This is plenty for handling the wicker cage and the black rod, but it might be embarrassing at a meeting of the Justice League to find that KISS SUPERHERO and KISS SUPERHEROINE read as if they are the same command.
I ran into problems with this myself in my first published game Ether, where I had 3d directions like NORTHEASTUP and SOUTHWESTDOWN. I thought I had found a way or been told a way to change this limit, but I looked through my source code and didn’t see anything, and just now trying it it can’t distinguish between NORTHEASTUP and NORTHEASTDOWN, so that’s odd. Fortunately I implemented shortcuts like NEU and NED.
Back to the text:
[T]he player begins in the Cobble Crawl because it was the first room created in the source text, but we could instead have written text like:
The player is in the Cobble Crawl.
This is one of those things that is a great convenience for new authors but mildly frustrating for experienced ones. Whatever room is listed first in the code is the one you get placed in unless you specify otherwise. In the past I remember mentioning a room once, many lines away from the rest of its code, so it’d be the first room.
Now let’s look at the examples! Sample programs 2 through 4. Since there are 400 examples in the text, I will only point out interesting features as they come.
The very first example includes some code ‘not for release’:
When play begins (this is the run property checks at the start of play rule):
repeat with item running through things:
if description of the item is "":
say "[item] has no description."
I use something like this a lot, but I print out everything:
Alldescriptioning is an action out of world. Understand "alldesc" as alldescriptioning.
Carry out alldescriptioning:
repeat with current running through things:
if current is not nothing:
say "[current]: [description of current][paragraph break]"
I run this through spellcheckers some times (although heaven knows they don’t catch everything).
Example 2 is just two rooms with long descriptions, with the game having the ‘brief room descriptions’ setting to try out.
Example 3 is interesting to me, as it has a way of changing the description of a room after the first time it’s seen that’s different than what I usually use (this is a partial snippet):
Slightly Wrong Chamber is south of the Awning. "[if unvisited]When you first step into the room, you are bothered by the sense that something is not quite right: perhaps the lighting, perhaps the angle of the walls. [end if]A mural on the far wall depicts a woman with a staff, tipped with a pine-cone. She appears to be watching you."
I always use [first time]…[only] for this instead of [if unvisited], but recently I’ve been wanting a way to ‘restart’ the first time only thing, so I wonder if this would work better, as I’m pretty sure you can say stuff like ‘now ThisRoom is unvisited’ or something. Could be worth a shot.
Some further fine print: we might write our condition as “if unvisited”, “if the location is unvisited”, or “if the Chamber is unvisited” – all of these constructions would be acceptable, but in the absence of more specifics, the condition is understood to apply to the object whose description it is.
This is something I never realized until recently. I have been struggling so much with how to refer to the current noun being referenced inside of its description; apparently you just don’t use any noun at all. Here’s an example from my code (that I got help with):
A climbing-rock has a nato-code. Understand the nato-code property as describing a climbing-rock. A climbing-rock is usually alfa. After printing the name of a climbing-rock: say " labelled '[nato-code]'". The description of a climbing-rock (called currentrock) is usually "This is a rock labelled [nato-code], attached to the climbing wall."
So I thought I’d have to type ‘nato-code of the noun’ or ‘nato-code of the noun described’ but you just say ‘nato-code’ and it understands automatically that it’s nato-code of the current thing.
Anyway, that was a big section. On to 3.2, Rooms and the Map!
Here we list all the directions: compass directions (N,NE,E,SE,S,SW,W,NW), UP and DOWN, and:
Two more directions are provided by Inform: “inside” and “outside”. These are best used when one location is, say, a meadow and the other is a woodcutter’s hut in the middle of it; we might then say
Inside from the Meadow is the woodcutter's hut.
The “from” is important, as it clarifies that we intend to link two different locations, not to create an item - the hut - in a single location - the meadow.
I struggled with inside and outside when writing 77 Verbs because typing OUT in inform can mean both exiting a supporter/container and going outside. I thought the inform names for the directions were just IN and OUT for a while.
A problem which sometimes arises when laying out maps is that Inform allows short forms of room names to be used as abbreviations. This is usually a good idea, but has unfortunate results if we write:
The Airport Road is west of the Fish Packing Plant. The Airport is west of the Airport Road.
…because “Airport” is taken as a reference to “Airport Road”, so Inform makes only two locations, one of which supernaturally leads to itself. We can avoid this by writing:
The Airport Road is west of the Fish Packing Plant. A room called the Airport is west of the Airport Road.
In small games I avoid this by just not naming things with names I’ve already used, but in my giant game, I have everything private-named. For instance, I have ten different ‘buttons’ in my game in wildly different circumstances (from an organ stop in Dracula’s library to a Sphinx’s nose to an evidence machine in a futuristic police department). So I have them all named stuff like ‘soda-button’ and just change their printed name and what their synonyms are.
He does offer an intriguing option which I might actually use (could be a good time to use the options.txt mentioned in the last chapter?)
If we really want to get rid of this issue once and for all, starting the source text with the use option “Use unabbreviated object names.” will do it, but the effect is drastic. This instructs Inform not to recognise names other than in full. For example:
West of the Kitchen is the Roaring Range. South of the Range is the Pantry.
is ordinarily read by Inform as constructing three rooms (Kitchen, Roaring Range, Pantry); but with this use option set, it makes four (Kitchen, Roaring Range, Range, Pantry), in two disconnected pieces of map. Handle with care.)
The first example in this section is Port Royal, a recurring example that is usually used to tack on very small changes that don’t merit a full game. This is its first appearance, though, so it has a little more substance, describing several streets, alleys, and a tavern.
Looking at the World tab of the Index, we can also see a schematic map of the simulation as it currently stands.
This is true, and I use my map in the Index a lot, especially since I have a lot of rules that only function in certain regions and the Index map color-codes regions.
Next is Up and Up, which adds a nice way to add a transition between rooms:
Before going to the Endless Tower:
say "You climb... and climb... and climb... The sun sets. The moon rises. The wind begins to blow. You continue to climb..."
I’d caution that players often won’t see this if the next room is big, as it prints before the bold heading and the new room description. You can fix this by making it very noticeable (I’ve used lines of asterisks) or by adding a ‘wait for any key’ type feature.
Last is our first 3-star example, Starry Void. This has a ‘room’ you can see from the outside. I usually just make a scenery object for the room and put a door in it or allow a command for entering, but they suggest making the object itself be a door:
The magician's booth is a door. "[if the player is in Center Ring]A magician's booth stands in the corner, painted dark blue with glittering gold stars.[otherwise if the magician's booth is closed]A crack of light indicates the way back out to the center ring.[otherwise]The door stands open to the outside.[end if]".
Section 3.3 is ‘One-way Connections’. This just points out that Inform automatically makes two-way connections, but that we can override that by describing each connection separately:
The Debris Room is west of the Crawl.
The Hidden Alcove is east of the Debris Room.
and even make a ‘blank’ connection one way:
East of the Debris Room is nowhere.
I’ve used that recently to make a ‘boneyard’ area like Spellbreaker where you end up after dying. You can leave it but can’t come back without dying again.
Bizarrely, being more specific can actually remove connections:
Finally, note that Inform’s assumptions about two-way directions are only applied to simple sentences. When the source text seems to be saying something complicated, Inform takes it as a precise description of what’s wanted. So, for example, in:The Attic is above the Parlour. The Attic is a dark room above the Parlour.
Inform makes guesses about the first sentence, and makes a two-way connection; but it accepts the second sentence more precisely, with just a one-way connection.
The first example here is Port Royal again, but with asymmetrical connections, which I detest on principle (but is important in a recipe book since authors often want them).
Next is a simple elevator that changes what exit it is every time you enter it (this is a pretty slick method):
After going to the Secret Elevator:
say "The doors automatically close, there is a rush of motion, and they open again.";
if UNCLE Headquarters is mapped west of the Secret Elevator, now Del Floria's Tailor Shop is mapped west of the Secret Elevator;
otherwise now UNCLE Headquarters is mapped west of the Secret Elevator;
continue the action.
Section 3.4 is Regions and the Index Map.
Regions are a nice way to clump things together. For instance:
The Arboretum is east of the Botanical Gardens. Northwest of the Gardens is the Tropical Greenhouse.
The Public Area is a region. The Arboretum and Gardens are in the Public Area.
This is mostly just a preview for future things. Important to note, though, that:
Regions can be put inside each other:
The University Parks is a region. The Public Area is in the University Parks.
but they are not allowed to overlap other than by one being entirely inside the other.
This is very useful if you have areas with very different responses from others (for instance, an underwater region where actions like jumping and swimming should all have similar responses in a cluster of rooms).
Port Royal is given another example where it is divided into regions.
Now we’re getting good. Section 3.5 is about Kinds, which I’ve found very useful, and is an example of the rule-based programming that makes Inform work better (to me) than interaction-based languages like Adrift and Adventuron.
Kinds are categories of objects with similar sets of interactions. He lists some examples:
Garden, Gazebo, Treehouse - room
billiards table - supporter
cup - container
starting pistol - thing
East, up (implied by “above”) - direction
Not mentioned here is the best thing about kinds, that you can make your own.
For some bizarre reason, the first example game in this section doesn’t have anything to do with kinds, but instead shows how you can provide synonyms for nouns:
Understand "tv" and "telly" as the television.
Perhaps it’s because this example also includes a device, which is a kind? But devices weren’t listed in the text, so…
Example 12 just shows how you can make Inform implicitly assume the kind of thing by the way you describe it:
East of the Garden is the Gazebo. Above is the Treehouse. A billiards table is in the Gazebo. On it is a trophy cup. A starting pistol is in the cup. In the Treehouse is a container called a cardboard box.
Section 3.6, either/or properties, lists the following useful properties:
open/closed
transparent/opaque
openable/unopenable
fixed in place/portable
enterable/?
I use these all the time. My current game has a lot of open unopenable transparent containers in it.
Hanon Ondricek used these to good effect in his IFComp 2014 blurb for Transparent (which sadly is not reproduced in its IFDB page):
There is a house. There is a room in the house. There is a door in the room. The door is locked. Some people are in the room. Some people are transparent.
Example 13 is in this section: ‘Tamed’. It describes a lion’s cage:
The Center Ring is a room. The cage is in the Center Ring. A lion is an animal in the cage. The cage is enterable, openable, transparent, and closed.
and a pedestal:
The pedestal is in the Center Ring. It is enterable. The player is on a pedestal.
and a magician’s booth:
The magician's booth is a container in Center Ring. "Off to one side is a magician's booth, used in disappearing acts. The exterior is covered with painted gilt stars." The booth is enterable, open, not openable, and fixed in place.
Section 3.7 is Properties Depending on Kind. It just says that some things are automatically assumed about kinds, like that all supporters like tables are not able to be picked up, but this can be changed by saying ‘The table is portable’.
This section has the first example of Disenchantment Bay, a running example. Similar to last section, it uses properties like ‘transparent’ and ‘openable’ for a glass case, but also introduces plural indefinite articles:
The bench is in the cabin. On the bench are some blue vinyl cushions.
Using “some” rather than “a” or “the” tells Inform that the cushions are to be referred to as a plural object in the future
Since this update is close to 3000 words, I’ll stop here (I think that’ll be my goal). I might do another one later today or not, but next up will be scenery!