|
Doe's Inform 6 PrimerI'd call it a faq except no one asked me frequently enough. ;-)This primer is still under construction. In writing this "primer" I focused on what I found "hardest" when learning Inform. Based on the premise that what I found tricky, others might too. However, I really had to cast my mind back, because I know Inform fairly well now. Also, when I started learning it I already knew how to program, so I didn't start from ground zero. In other words, this doesn't cover the basics of how to program and/or more than a few basics of Inform (read the Inform Designer's Manual and the Inform Beginner's Guide), but newbies may still get something out of it. |
|
>ask the troll about the sword
>hit the troll >cut the troll with the sword >give the lantern to the troll |
|
>
ask
the
troll
about the
sword
> hit the troll > cut the troll with the sword > give the lantern to the troll |
parser.h <- the parser grammar.h <- grammar definitions (mainly verbs) verblib.h <- verb programming routines that perform the actual actions1 Prepositions connection to verbs can be defined when you create new verbs or extend existing verbs. And new articles, such as some, can be defined for plural nouns and other objects that require special articles.
|
>
ask
the troll about the sword
> hit the troll > cut the troll with the sword > give the lantern to the troll |
|
>ask the troll about the sword
There is no reply. >hit the troll Violence isn't the answer to this one. >Cut the troll with the sword. You aren't holding the sword. >give the lantern to the troll Done. (removes lantern from player's inventory) |
|
>ask the
troll
about the
sword
>hit the troll >cut the troll with the sword >give the lantern to the troll |
parser.h - Defines the Inform library version and fake actions.
Includes parserm.h.
parserm.h - Declares the player and the dark objects and contains the parser.
Includes linklpa.h and english.h (language.h*).
linklpa.h - Defines the global attributes and properties.
linklv.h - Defines other global variables that are used by the library
in conjunction with Inform compiler.
english.h - Contains the standard library messages (responses to verbs
and other messages). english.h will be called something else
if the game is written in another language other than English.*
grammar.h - Defines the verbs and links them to the verb routines that will
be performed when the verbs are used.
verblib.h - Defines some constants (that relate to actions).
Includes verblibm.h.
verblibm.h - Declares the verb routines and contains other supporting routines.
Includes linklpa.h and linklv.h.
Because several include files include other include files, you only need to
include three in your code:
parser.h,
grammar.h,
and
verblib.h.
To
include
one, use the following type of statement.
#include "parser"The ".h" can be dropped from (or included in) in the statement.
|
Inform compiler switches
Constant Story Constant Headline #include "parser" #include "verblib" Initialise routine game objects #include "grammar" |
!----------------------------------------------------------------------------
! Globals
!----------------------------------------------------------------------------
! Example Troll I.
Switches xdv5s;
Constant Story "^^Troll Example I^";
Constant Headline "by Doe^";
#include "parser";
#include "verblib";
!----------------------------------------------------------------------------
! Initialization Routine
!----------------------------------------------------------------------------
[ Initialise;
location = cave;
move sword to player;
"^^You don't know how you got here...";
];
!----------------------------------------------------------------------------
! Objects
!----------------------------------------------------------------------------
Object sword "sword"
with name "sword" "blade" "knife",
description "It appears to be an ordinary sword.";
Object cave "Cave"
has light
with description "You are high, vaulting cave. The far reaches are in
darkness.";
Object -> troll "troll"
has animate
with name "troll" "big" "ugly" "guy",
description "He's just as big, ugly, and dumb-looking as you always thought
a troll would be.";
!----------------------------------------------------------------------------
! Verbs
!----------------------------------------------------------------------------
#include "grammar";
Layout with New Verbs
|
Inform compiler switches
Constant Story Constant Headline #include "parser" replacement statements #include "verblib" Initialise routine game objects #include "grammar" new/extended verbs |
!----------------------------------------------------------------------------
! Globals
!----------------------------------------------------------------------------
! Example Troll II.
Switches xdv5s;
Constant Story "^^Troll Example II^";
Constant Headline "by Doe^";
#include "parser";
Replace CutSub;
#include "verblib";
!----------------------------------------------------------------------------
! Initialization Routine
!----------------------------------------------------------------------------
[ Initialise;
location = cave;
move cloak to player;
move sword to player;
move lantern to player;
"^^You don't know how you got here...";
];
!----------------------------------------------------------------------------
! Objects
!----------------------------------------------------------------------------
Object cloak "cloak"
has clothing worn
with name "cloak" "cape",
description "It is a plain black cloak, but it swishes dramatically.",
before
[; Attack : "Then you'd have nothing to swish."; ];
Object sword "sword"
with name "sword" "blade" "knife",
description "It appears to be an ordinary sword.";
Object lantern "lantern"
has light
with name "lantern" "light",
description "It looks strangely familiar.",
before
[; Attack : "If you broke the lantern you would be without light."; ];
Object cave "Cave"
with description "You are high, vaulting cave. The far reaches are in
darkness.";
Object -> troll "troll"
has animate
with name "troll" "big" "ugly" "guy",
description "He's just as big, ugly, and dumb-looking as you always thought
a troll would be.";
!----------------------------------------------------------------------------
! Verbs
!----------------------------------------------------------------------------
#include "grammar";
Extend 'cut' replace
* noun 'with' held ->Cut;
Extend 'attack'
* noun 'with' held ->Cut;
Verb 'swish' 'swirl'
* ->Swish
* noun ->Swish;
[ CutSub;
if ((second ~= sword) || (noun == sword)) "Huh?";
<<Attack noun>>
];
[ SwishSub;
if ((noun == 0) || (noun ~= cloak))
"Interesting, didn't realize you had that preference.";
if (cloak hasnt worn)
"But you aren't wearing the cloak.";
"You swish the cloak dramatically. Ahhh.";
];
Attribute Summary
| Attribute | Description |
| light | Location that has light. If the location doesn't have light, doesn't contain an object that provides light, or the player isn't carrying an object that provides light, then the player will be in the dark (actually in thedark object). |
| visited | Location that has been visited before. The Inform library automatically assigns visited to a location when it is first visited (after the first look which is preformed automatically). Visited rooms may give an abbreviated description the next time look is used. |
| scored | Location which will add to the score when visited for the first time. |
| Attribute | Description |
| scenery | Object which will not show up in the room description, but it can be examined and manipulated (touched, etc.) if properties are included for that. When player attempts to take object, "That's/They're hardly portable.", will be printed. Player is also "unable" to push, pull, or turn it. |
| static | Object which will show up in the room description, but when the player attempts to take it, "That's/They're fixed in place.", will be printed. The same message is also printed if the player attempts to remove, push, pull, or turn it. |
| Attribute | Description |
| concealed | Object which will not show up in the room description, but once the player knows it is there, it can be referred to and taken (if its before routine allows it). |
| moved | Object that has been or is being held by the player. The Inform library automatically assigns moved to an object when it is taken by the player (in the player's inventory). An object that has not been moved and has an initial property, and its initial description will be printed after the room description. |
| light | Object that provides light, such as a lantern. |
| switchable | Object that can be switched on or off. |
| on | A switchable object that is on. The Inform library automatically assigns on to an object when the object is switched on (and on is made false when the object is switched off). |
| talkable | Object that the player can talk to, such as a microphone. However, a talkable object does not have a life routine so it will not respond to other character interaction (see "live" objects). |
| edible | Object that can be eaten, thus removed from the game. |
| clothing | Object that can be worn by the player. |
| worn | Object that is currently being worn by the player. Usually used with clothing. |
| proper | Object which will be referred to by its name without a preceeding the/a ("proper name"). |
| pluralname | Pronouns referring to this object will be plural -- them or some. |
| scored | Object which will add to the score when picked up for the first time. |
| Attribute | Description |
| supporter | Object that hold things and is considered to be a "flat-surface." The objects it holds will be described as being "on" it. |
| container | Object that can hold things and is considered to have sides and a lid (although they are not explicitly stated). The objects it holds will be described as being "in" it. |
| enterable | A supporter or container that the player can enter, but only if it is "on the floor" (not carried and not in/on something else). |
| openable | Used with container, a container that can be opened (if it is not locked). |
| open | Used with container and openable, an openable container that is currently open. The Inform library automatically assigns open to an object when it is opened (and open is made false when it is closed). |
| lockable | Used with container, a container that can be locked. |
| locked | Used with container and locked, a lockable container that is currently locked (and closed -- not open). If the object has the with_key property, the object designated by with_key can open it. |
| transparent | Used with container, a container that is transparent. The contents of a transparent container will be visible when it is closed. Also when the player is inside a closed transparent container they will be able to see the surrounding room. Inside a closed regular container, they will only be able to see the inside of the container. |
| Attribute | Description |
| supporter | Object that hold things and is considered to be a "flat-surface." The objects it holds will be described as being "on" it. |
| container | Object that can hold things and is considered to have sides and a lid (although they are not explicitly stated). The objects it holds will be described as being "in" it. |
| enterable | A supporter or container that the player can enter, but only if it is "on the floor" (not carried and not in/on something else). |
| openable | Used with container, a container that can be opened (if it is not locked). |
| open | Used with container and openable, an openable container that is currently open. The Inform library automatically assigns open to an object when it is opened (and open is made false when it is closed). |
| lockable | Used with container, a container that can be locked. |
| locked | Used with container and locked, a lockable container that is currently locked (and closed -- not open). If the object has the with_key property, the object designed by with_key can open it. |
| transparent | Used with container, a container that is transparent. The contents of a transparent container will be visible when it is closed. Also when the player is inside a closed transparent container they will be able to see the surrounding room. Inside a closed regular container, they will only be able to see the inside of the container. |
| Attribute | Description |
| animate | Only objects with the animate attribute can have the life property. The life property routine can provide responses for: Ask, Answer, Tell, Attack, ThrowAt, Kiss, Show, Give, Order, and WakeOther. In other words, an animate object can be conversed with and interacted with as if is a "live" character. (Note that the talkable attribute also allows conversation.) |
| male | Pronouns referring to this object will be masculine -- him. Usually used with animate. |
| female | Pronouns referring to this object will be feminine -- her. Usually used with animate. |
| neuter | Pronouns referring to this object will be gender neutral - it. Usually used with animate. |
| proper | Used with animate, character which will be referred by his/her/its "proper" name without a preceeded the/a -- Jack and Jill, not the boy and the girl. |
| transparent | Used with animate, everything the character is carrying can be referrable to by the player, although the held object descriptions are not automatically printed with the character description. |