Inform - Resources - Examples

Back to List

Inventory
Complete

Plain
Coloured
Gaudy

Browsing Alice2.inf

This is the complete source code of the example game Alice2.inf.

001  ! Through the Looking-Glass
002  ! An Inform tutorial by Gareth Rees
003  ! All rights given away
004  ! Version 2
005   
006  Constant Story "THROUGH THE LOOKING GLASS";
007  Constant Headline "^An Interactive Tutorial^by Gareth Rees^";
008  Constant DEBUG;
009   
010  Include "parser";
011  Include "verblib";
012  Include "grammar";
013   
014  [ Initialise;
015      location = Drawing_Room;
016      print "^^^^^It's a cold winter day outside, but in the looking-glass
017          house it's summer. All you need to do is pretend there's a way of
018          getting through into it somehow...^^";
019  ];
020   
021  [ UntangleSub; "What curious ideas you have!"; ];
022   
023  Verb "roll" "untangle" "wind"
024      * noun -> Untangle
025      * "up" noun -> Untangle
026      * noun "up" -> Untangle;
027   
028  Object  Drawing_Room "Drawing room"
029   has    light
030   with   name "snow",
031          description "The gentle sound of snow against the window pane
032              suggests that it's cold outside, and you're glad to be here
033              in the warmth. The drawing-room is reflected in the large
034              looking-glass on the wall above the mantelpiece, and a very
035              comfortable room it is too, with a warm hearth, a soft rug
036              and an arm-chair that you can curl up and sleep in.";
037   
038  Object  red_queen "red queen"
039   with   name "red" "queen",
040          description "She's a fierce little chess piece.";
041   
042  Object  chess_board "chess board" Drawing_Room
043   has    supporter
044   with   name "chess" "board" "checker" "chequer" "chessboard",
045          initial "An abandoned chess board lies on the floor.",
046          description "It's left here from the game you were playing just
047              now, but the pieces are all missing - the kittens will insist
048              on playing with them.";
049   
050  Object  hearth "hearth" Drawing_Room
051   has    scenery
052   with   name "hearth" "fire" "place" "fireplace",
053          description "Looking at the hearth, you wonder if they have a
054              hearth in the looking-glass house. You can never tell by
055              looking, unless your fire smokes, and then smoke comes up in
056              the looking-glass room too - but that may be only pretence,
057              just to make it look as if they had a fire.";
058   
059  Object  rug "rug" Drawing_Room
060   has    concealed static supporter enterable
061          ! general if you've found the red queen under it
062   with   name "hearthrug" "hearth-rug" "rug" "indian" "arabian" "beautiful"
063              "soft", 
064          description "It's a beautiful rug, made in some far off country,
065              perhaps India or Araby, wherever those might be.",
066          before [;
067           Take: "The rug is much too large and heavy for you to carry.";
068           Push,Pull: "But a hearth-rug is meant to be next to the hearth!";
069           LookUnder:
070              if (player in self)
071                  "You try to lift up a corner of the rug, but fail. After
072                  a while, you realise that this is because you are
073                  standing on it. How curious the world is!";
074              if (self hasnt general) {
075                  give self general;
076                  move red_queen to player;
077                  "You lift up a corner of the rug and, peering underneath,
078                  discover the red queen from the chess set.";
079              }
080          ];
081   
082  Object  armchair "arm-chair" Drawing_Room
083   has    static concealed supporter enterable
084          ! general if its by the mantelpiece
085   with   name "arm" "chair" "armchair" "arm-chair",
086          description "It's a huge arm-chair, the perfect place for a kitten
087              or a little girl to curl up in and doze.",
088          before [;
089           Push,Pull:
090              ! code to check for the kittens
091              if (self has general) {
092                  give self ~general;
093                  "You push the arm-chair away from the hearth.";
094              }
095              give self general;
096              "You push the arm-chair over to the hearth.";
097          ];
098   
099  Object  mantelpiece "mantelpiece" Drawing_Room
100   has    concealed supporter enterable
101   with   name "mantel" "mantelpiece",
102          description "It's higher off the ground than your head, but it
103              looks wide enough and sturdy enough to support you.",
104          before [;
105           Enter,Climb:
106              if (player notin armchair)
107                  "The mantelpiece is much too high to climb up onto.";
108              if (armchair hasnt general)
109                  "You can't reach the mantelpiece from here.";
110              if (children(player) > 0)
111                  "Your hands are too full.";
112           PutOn,LetGo:
113              if (player notin self && (player notin armchair || 
114                  armchair hasnt general))
115                  "The mantelpiece is so high that you can't reach.";
116          ];
117   
118  Object  mirror "looking-glass" Drawing_Room
119   has    static concealed
120   with   name "mirror" "looking" "glass" "looking-glass",
121          description [;
122              if (player in mantelpiece)
123                  "Strangely, the glass is beginning to melt away, just
124                  like a bright silvery mist.";
125              if (player in armchair)
126                  "In the looking-glass you can see the drawing-room of the
127                  looking-glass house. What you can see is very much the
128                  same as this drawing-room, only all reversed, left for
129                  right. But you are sure that out of the corners of the
130                  glass, where you can't see, the looking-glass world is
131                  quite different from yours.";
132              "In the looking-glass you can see the ceiling of the
133              drawing-room of the looking-glass house. It looks much the
134              same as the ceiling of your drawing-room.";
135          ],
136          before [;
137              if (action ~= ##Examine && player notin mantelpiece)
138                  "You can't reach the looking-glass from where you're
139                  standing.";
140           Touch,Pull,Push:
141              "Your hand goes right through the silvery mist!";
142           Enter:
143              ! Really, move Alice to the looking-glass house.
144              deadflag = 2;
145              "Your hand goes right through the silvery mist, and in
146              another moment the rest of you follows, and you are through
147              the glass...";
148          ];
149   
150  Object  worsted "ball of worsted" Drawing_Room
151          ! general if its in a tangle
152   with   name "ball" "of" "worsted" "fine" "blue" "wool",
153          initial "A discarded ball of worsted lies on the floor here.",
154          description [;
155              if (self has general)
156                  "It's in a terrible tangle. All that time you spent
157                  rolling it up, and now look at it!";
158              "It's a ball of fine blue wool, all rolled up in preparation
159              for some embroidery.";
160          ],
161          before [;
162           Untangle: "You're as quick as can be at rolling up balls of
163              wool, though you say so yourself! Soon it's neat and tidy
164              again.";
165          ];
166   


Last updated 23 June 2004. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.