Sunday, July 17, 2011

Inform Object Lessons

Following yesterday’s intro to Inform post, this will still be about objects.

Objects can have properties: A person can be male, female, or neuter. Adam is a man. Adam is Male. A Horse is a kind of animal. The clydesdale mare is a female horse. The description of the clydesdale mare is “A large magnificent horse with a mostly brown pelt broken up by patches of whte.”. A female horse can be in-heat. The clydesdale mare is in-heat.

In-heat is an either/or property. The description is a value property where the value is some text, specifically the text that is printed on examining the mare (looking at the mare).

When creating something, quoted text can follow the sentence to save time.

The barn is a room. “The old barn is a bit musty and filled with hay dust.”.
The clydesdale stallion is a male horse in the horse field. “There is a giant stallion standing in the field, eyeing the mare.”.


Text after a room will be used as the description. Text after a thing will be the initial appearance, text shown in the room description, in this case giving the horse a separate paragraph after the field is described. This initial appearance vanishes once the thing is handled by the player, and is commonly used to make objects stand out in rooms.

Inform also infers a lot of things, if that was the first time the horse field was mentioned, Inform would assume it was a room and create a room called the horse field.

A note on a/an/the/some, Inform doesn’t care about grammar and strips these words from code, so Clydesdale Stallion is male horse in horse field. works just as well. A/an/the/some however would tell Inform which to use when describing the stallion if used when the stallion is created in the code. Likewise for capitalization, if it is written ‘The Clydesdale stallion is...’ when created, then the horse field might look like:

Horse Field

You can see the Clydesdale stallion here. (if the stallion had that initial appearance from earlier, this would be ‘There is a giant stallion standing in the field, eyeing the mare.’ instead).

---

Inform has some built in properties and values, which are handy to know about.

privately-named/publicly-named : by default all items are publicly-named, which is to say the name of the Clydesdale stallion will be Clydesdale stallion by default, and the player can type “Look Clydesdale / Look Stallion / Look clydesdale stallion” to examine the stallion.

The printed name of ___ : This is the printed singular name of something, useful for when names need to change, or an object is privately named.

Now the printed name of the clydesdale stallion is “Dale”. The printed name of object-403 is “office copy machine”.

Inform won’t understand the player typing ‘look dale’ but stallion and clydesdale will still work.

Understand “Dale” as the clydesdale stallion. Now Inform properly understands dale when the layer tries ‘look dale’.

The printed plural name of ____ : same thing, although typically only a generic kind can have multiple instances. Not always needed since Inform can pluralize most names anyways.

A clydesdale is a kind of horse. There are three male clydesdales in the field. There are 2 female clydesdales in the barn. ( You can see three clydesdales in the field. )

The printed plural name of clydesdales is "herd of clydesdales". ( You can see a herd of Clydesdales in the field.)
---

The old barn is a dark room. This creates a room where the player only sees darkness unless the player carries a light source, because 'dark' is a built-in either/or property for rooms. The flashlight is a lit thing carried by the player. This creates something called a flashlight, that provides light, carried by the player at the start of the game. The player can now enter the old barn and see a room description(if provided) and any objects that might be in the old barn.

---

The rickety shelf is a scenery supporter in the old barn. Scenery is a property that makes something a background object. If there is nothing on the shelf it won’t be mentioned as an item in the old barn, but the player can ‘Look shelf’ and see it. Scenery is commonly used for things mentioned in the room description the player might interact with, and in the case of a supporter, putting something on it will make it stand out a bit. There is an old lantern on the rickety shelf. ( You can see an old lantern on the rickety shelf here.) When nothing is on the shelf it will once again become part of the background. Scenery is all by default fixed in place.

Fixed in Place is an item property for things that player can’t pick-up. The fridge is a closed openable container in the kitchen. The fridge is fixed in place.

Closed/Open Openable/Not Openable: This is a fairly obvious set of properties for a thing, openable means close/open actions will work on it. Not openable means it is stuck in the current position. Typically found on doors and containers.

Locked/Unlocked Lockable/Not lockable: This works just like open/closed, except for one thing. Lockable things can have keys. The matching key of the fridge is the banana magnet. / The banana magnet unlocks the fridge. / The fridge has matching key the banana magnet. They all work equally well and set the banana magnet as the thing that unlocks the fridge.

Carrying Capacity: A limit on containers and people on the number of items that can be carried. By default 100 things. Also the reason for the player’s holdall kind.

---

Now for the relationships built into Inform. These can be found in chapter 13 of the Inform documentation:

containment relation - The coin is in the purse.
support relation - The coin is on the table.
incorporation relation - The coin is part of the sculpture.
carrying relation - The coin is carried by Peter.
wearing relation - The jacket is worn by Peter.
possession relation - if Mr Darcy has a rapier...
adjacency relation - The Study is east of the Hallway.
visibility relation - if Darcy can see Elizabeth...
touchability relation - if Darcy can touch Elizabeth...

Containment for example can be done in multiple ways:

The coin is in the purse.
The purse contains the coin.
The coin is contained by the purse.

There are five relations between objects that are mutually exclusive:

containment relation - The coin is in the purse.
support relation - The coin is on the table.
incorporation relation - The coin is part of the sculpture.
carrying relation - The coin is carried by Peter.
wearing relation - The jacket is worn by Peter.  

If two items have one of those relationships, then it can’t have the other four.

For instance: If the jacket is carried by the player, now the jacket is worn by the player. This makes the jacket worn, but also makes it not carried.

Of these relations built into Inform, one probably needs the most explaining, Incorporation.

The desk is a supporter in the office. A closed openable container called the top drawer is part of the desk. A closed openable container called the bottom drawer is part of the desk.

By default these parts of the desk will work like scenery, they go where ever the desk goes and won’t generally be mentioned separate from the desk, although code can be written to say mention open drawers and their contents. They should therefor be mentioned in the desk description at least to let the player know they’re there.

The player will be able to put things on the desk, but not open it. We could redirect that attempt however.

Instead of opening the desk:
If the top drawer is open:
say “The top drawer is already open” instead;
If the top drawer is not open:
Now the top drawer is open;
say “You open the top drawer.” instead.


This can be a lot of hassle, particularly if we also want to intercept trying to put things in the desk. One solution is to simply make the desk a container, the top drawer as it were, renaming the top drawer to middle drawer.

Another is to use a special command.

Understand open desk as a mistake (“You should try opening a particular drawer of the desk.”).

This is a special command to intercept a command the player might try and print a message to redirect the player to something else. Details on this can be found in 16.20 of the Inform documentation.

0 comments:

Post a Comment