Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing Advent.inf

3. The outside world (lines 82-480)

0082  Class   Room;
0083   
0084  Class   Aboveground
0085    class Room
0086    has   light nodwarf;
0087   
0088  Class   Scenic
0089    has   scenery;
0090   
0091  Aboveground At_End_Of_Road "At End Of Road"
0092    with  name 'end' 'of' 'road' 'street' 'path' 'gully',
0093          description
0094              "You are standing at the end of a road before a small brick building.
0095               Around you is a forest.
0096               A small stream flows out of the building and down a gully.",
0097          w_to At_Hill_In_Road,
0098          u_to At_Hill_In_Road,
0099          e_to Inside_Building,
0100          d_to In_A_Valley,
0101          s_to In_A_Valley,
0102          n_to In_Forest_1,
0103          in_to Inside_Building;
0104   
0105  Scenic  "well house"
0106    with  name 'well' 'house' 'brick' 'building' 'small' 'wellhouse',
0107          description "It's a small brick building. It seems to be a well house.",
0108          found_in At_End_Of_Road At_Hill_In_Road Inside_Building,
0109          before [;
0110            Enter:
0111              if (location == At_Hill_In_Road && Inside_Building hasnt visited)
0112                  "It's too far away.";
0113              <<Teleport Inside_Building>>;
0114          ];
0115   
0116  Scenic  Stream "stream"
0117    with  name 'stream' 'water' 'brook' 'river' 'lake' 'small' 'tumbling'
0118               'splashing' 'babbling' 'rushing' 'reservoir',
0119          found_in At_End_Of_Road In_A_Valley At_Slit_In_Streambed In_Pit
0120                   In_Cavern_With_Waterfall At_Reservoir Inside_Building,
0121          before [;
0122            Drink:
0123              "You have taken a drink from the stream.
0124               The water tastes strongly of minerals, but is not unpleasant.
0125               It is extremely cold.";
0126            Take:
0127              if (bottle notin player)
0128                  "You have nothing in which to carry the water.";
0129              <<Fill bottle>>;
0130            Insert:
0131              if (second == bottle) <<Fill bottle>>;
0132              "You have nothing in which to carry the water.";
0133            Receive:
0134              if (noun == ming_vase) {
0135                  remove ming_vase;
0136                  move shards to location;
0137                  score = score - 5;
0138                  "The sudden change in temperature has delicately shattered the vase.";
0139              }
0140              if (noun == bottle) <<Fill bottle>>;
0141              remove noun;
0142              if (noun ofclass Treasure) score = score - 5;
0143              print_ret (The) noun, " washes away with the stream.";
0144          ];
0145   
0146  Scenic  "road"
0147    with  name 'road' 'street' 'path' 'dirt',
0148          description "The road is dirt, not yellow brick.",
0149          found_in At_End_Of_Road At_Hill_In_Road In_Forest_2;
0150   
0151  Scenic  "forest"
0152    with  name 'forest' 'tree' 'trees' 'oak' 'maple' 'grove' 'pine' 'spruce'
0153               'birch' 'ash' 'saplings' 'bushes' 'leaves' 'berry' 'berries'
0154               'hardwood',
0155          description
0156              "The trees of the forest are large hardwood oak and maple,
0157               with an occasional grove of pine or spruce.
0158               There is quite a bit of undergrowth,
0159               largely birch and ash saplings plus nondescript bushes of various sorts.
0160               This time of year visibility is quite restricted by all the leaves,
0161               but travel is quite easy if you detour around the spruce and berry bushes.",
0162          found_in At_End_Of_Road At_Hill_In_Road In_A_Valley In_Forest_1 In_Forest_2,
0163    has   multitude;
0164   
0165  ! ------------------------------------------------------------------------------
0166   
0167  Aboveground At_Hill_In_Road "At Hill In Road"
0168    with  name 'hill' 'in' 'road',
0169          description
0170              "You have walked up a hill, still in the forest.
0171               The road slopes back down the other side of the hill.
0172               There is a building in the distance.",
0173          e_to At_End_Of_Road,
0174          n_to At_End_Of_Road,
0175          d_to At_End_Of_Road,
0176          s_to In_Forest_1;
0177   
0178  Scenic  -> "hill"
0179    with  name 'hill' 'bump' 'incline',
0180          description "It's just a typical hill.";
0181   
0182  Scenic  -> "other side of hill"
0183    with  name 'side' 'other' 'of',
0184          article "the",
0185          description "Why not explore it yourself?";
0186   
0187  ! ------------------------------------------------------------------------------
0188   
0189  Aboveground Inside_Building "Inside Building"
0190    with  name 'inside' 'building' 'well' 'house' 'wellhouse',
0191          description
0192              "You are inside a building, a well house for a large spring.",
0193          cant_go
0194              "The stream flows out through a pair of 1 foot diameter sewer pipes.
0195               The only exit is to the west.",
0196          before [;
0197            Enter:
0198              if (noun == Spring or SewerPipes)
0199                  "The stream flows out through a pair of 1 foot diameter sewer pipes.
0200                   It would be advisable to use the exit.";
0201            Xyzzy:
0202              if (In_Debris_Room hasnt visited) rfalse;
0203              PlayerTo(In_Debris_Room);
0204              rtrue;
0205            Plugh:
0206              if (At_Y2 hasnt visited) rfalse;
0207              PlayerTo(At_Y2);
0208              rtrue;
0209          ],
0210          w_to At_End_Of_Road,
0211          out_to At_End_Of_Road,
0212          in_to "The pipes are too small.";
0213   
0214  Scenic  -> Spring "spring"
0215    with  name 'spring' 'large',
0216          description
0217              "The stream flows out through a pair of 1 foot diameter sewer pipes.";
0218   
0219  Scenic  -> SewerPipes "pair of 1 foot diameter sewer pipes"
0220    with  name 'pipes' 'pipe' 'one' 'foot' 'diameter' 'sewer' 'sewer-pipes',
0221          description "Too small. The only exit is to the west.";
0222   
0223  Object  -> set_of_keys "set of keys"
0224    with  name 'keys' 'key' 'keyring' 'set' 'of' 'bunch',
0225          description "It's just a normal-looking set of keys.",
0226          initial "There are some keys on the ground here.",
0227          before [;
0228            Count:
0229              "A dozen or so keys.";
0230          ];
0231   
0232  Object  -> tasty_food "tasty food"
0233    with  name 'food' 'ration' 'rations' 'tripe' 'yummy' 'tasty' 'delicious' 'scrumptious',
0234          article "some",
0235          description "Sure looks yummy!",
0236          initial "There is tasty food here.",
0237          after [;
0238            Eat:
0239              "Delicious!";
0240          ],
0241    has   edible;
0242   
0243  Object  -> brass_lantern "brass lantern"
0244    with  name 'lamp' 'headlamp' 'headlight' 'lantern' 'light' 'shiny' 'brass',
0245          when_off "There is a shiny brass lamp nearby.",
0246          when_on "Your lamp is here, gleaming brightly.",
0247          daemon [ t;
0248              if (self hasnt on) {
0249                  StopDaemon(self);
0250                  rtrue;
0251              }
0252              t = --(self.power_remaining);
0253              if (t == 0) give self ~on ~light;
0254              if (self in player || self in location) {
0255                  if (t == 0) {
0256                      print "Your lamp has run out of power.";
0257                      if (fresh_batteries notin player && location hasnt light) {
0258                          deadflag = 3;
0259                          " You can't explore the cave without a lamp.
0260                           So let's just call it a day.";
0261                      }
0262                      else
0263                          self.replace_batteries();
0264                      new_line;
0265                      rtrue;
0266                  }
0267                  if (t == 30) {
0268                      print "Your lamp is getting dim.";
0269                      if (fresh_batteries.have_been_used)
0270                          " You're also out of spare batteries.
0271                           You'd best start wrapping this up.";
0272                      if (fresh_batteries in VendingMachine && Dead_End_14 has visited)
0273                          " You'd best start wrapping this up,
0274                           unless you can find some fresh batteries.
0275                           I seem to recall there's a vending machine in the maze.
0276                           Bring some coins with you.";
0277                      if (fresh_batteries notin VendingMachine or player or location)
0278                          " You'd best go back for those batteries.";
0279                      new_line;
0280                      rtrue;
0281                  }
0282              }
0283          ],
0284          before [;
0285            Examine:
0286              print "It is a shiny brass lamp";
0287              if (self hasnt on) ". It is not currently lit.";
0288              if (self.power_remaining < 30) ", glowing dimly.";
0289              ", glowing brightly.";
0290            Burn:
0291              <<SwitchOn self>>;
0292            Rub:
0293              "Rubbing the electric lamp is not particularly rewarding.
0294               Anyway, nothing exciting happens.";
0295            SwitchOn:
0296              if (self.power_remaining <= 0)
0297                  "Unfortunately, the batteries seem to be dead.";
0298            Receive:
0299              if (noun == old_batteries)
0300                  "Those batteries are dead; they won't do any good at all.";
0301              if (noun == fresh_batteries) {
0302                  self.replace_batteries();
0303                  rtrue;
0304              }
0305              "The only thing you might successfully put in the lamp
0306               is a fresh pair of batteries.";
0307          ],
0308          after [;
0309            SwitchOn:
0310              give self light;
0311              StartDaemon(self);
0312            SwitchOff:
0313              give self ~light;
0314          ],
0315          replace_batteries [;
0316              if (fresh_batteries in player or location) {
0317                  remove fresh_batteries;
0318                  fresh_batteries.have_been_used = true;
0319                  move old_batteries to location;
0320                  self.power_remaining = 2500;
0321                  "I'm taking the liberty of replacing the batteries.";
0322              }
0323          ],
0324          power_remaining 330,
0325    has   switchable;
0326   
0327  Object  -> bottle "small bottle"
0328    with  name 'bottle' 'jar' 'flask',
0329          initial "There is an empty bottle here.",
0330          before [;
0331            LetGo:
0332              if (noun in bottle)
0333                  "You're holding that already (in the bottle).";
0334            Receive:
0335              if (noun == stream or Oil)
0336                  <<Fill self>>;
0337              else
0338                  "The bottle is only supposed to hold liquids.";
0339            Fill:
0340              if (child(bottle) ~= nothing)
0341                  "The bottle is full already.";
0342              if (stream in location || Spring in location) {
0343                  move water_in_the_bottle to bottle;
0344                  "The bottle is now full of water.";
0345              }
0346              if (Oil in location) {
0347                  move oil_in_the_bottle to bottle;
0348                  "The bottle is now full of oil.";
0349              }
0350              "There is nothing here with which to fill the bottle.";
0351            Empty:
0352              if (child(bottle) == nothing)
0353                  "The bottle is already empty!";
0354              remove child(bottle);
0355              "Your bottle is now empty and the ground is now wet.";
0356          ],
0357    has   container open;
0358   
0359  Object  water_in_the_bottle "bottled water"
0360    with  name 'bottled' 'water' 'h2o',
0361          article "some",
0362          description "It looks like ordinary water to me.",
0363          before [;
0364            Drink:
0365              remove water_in_the_bottle;
0366              <<Drink Stream>>;
0367          ];
0368   
0369  Object  oil_in_the_bottle "bottled oil"
0370    with  name 'oil' 'bottled' 'lubricant' 'grease',
0371          article "some",
0372          description "It looks like ordinary oil to me.",
0373          before [;
0374            Drink:
0375              <<Drink Oil>>;
0376          ];
0377   
0378  ! ------------------------------------------------------------------------------
0379   
0380  Aboveground In_Forest_1 "In Forest"
0381    with  name 'forest',
0382          description "You are in open forest, with a deep valley to one side.",
0383          e_to In_A_Valley,
0384          d_to In_A_Valley,
0385          n_to In_Forest_1,
0386          w_to In_Forest_1,
0387          s_to In_Forest_1,
0388          initial [;
0389              if (random(2) == 1) PlayerTo(In_Forest_2, 1);
0390          ];
0391   
0392  Aboveground In_Forest_2 "In Forest"
0393    with  description "You are in open forest near both a valley and a road.",
0394          n_to At_End_Of_Road,
0395          e_to In_A_Valley,
0396          w_to In_A_Valley,
0397          d_to In_A_Valley,
0398          s_to In_Forest_1;
0399   
0400  Aboveground In_A_Valley "In A Valley"
0401    with  description
0402              "You are in a valley in the forest beside a stream tumbling along a rocky bed.",
0403          n_to At_End_Of_Road,
0404          e_to In_Forest_1,
0405          w_to In_Forest_1,
0406          u_to In_Forest_1,
0407          s_to At_Slit_In_Streambed,
0408          d_to At_Slit_In_Streambed,
0409          name 'valley';
0410   
0411  Scenic  -> "streambed"
0412    with  name 'bed' 'streambed' 'rock' 'small' 'rocky' 'bare' 'dry';
0413   
0414  ! ------------------------------------------------------------------------------
0415   
0416  Aboveground At_Slit_In_Streambed "At Slit In Streambed"
0417    with  name 'slit' 'in' 'streambed',
0418          description
0419              "At your feet all the water of the stream splashes into a 2-inch slit in the rock.
0420               Downstream the streambed is bare rock.",
0421          n_to In_A_Valley,
0422          e_to In_Forest_1,
0423          w_to In_Forest_1,
0424          s_to Outside_Grate,
0425          d_to "You don't fit through a two-inch slit!",
0426          in_to "You don't fit through a two-inch slit!";
0427   
0428  Scenic  -> "2-inch slit"
0429    with  name 'slit' 'two' 'inch' '2-inch',
0430          description
0431              "It's just a 2-inch slit in the rock, through which the stream is flowing.",
0432          before [;
0433            Enter:
0434              "You don't fit through a two-inch slit!";
0435          ];
0436   
0437  ! ------------------------------------------------------------------------------
0438   
0439  Aboveground Outside_Grate "Outside Grate"
0440    with  name 'outside' 'grate',
0441          description
0442              "You are in a 20-foot depression floored with bare dirt.
0443               Set into the dirt is a strong steel grate mounted in concrete.
0444               A dry streambed leads into the depression.",
0445          e_to In_Forest_1,
0446          w_to In_Forest_1,
0447          s_to In_Forest_1,
0448          n_to At_Slit_In_Streambed,
0449          d_to [;
0450              if (Grate hasnt locked && Grate hasnt open) {
0451                  print "(first opening the grate)^";
0452                  give Grate open;
0453              }
0454              return Grate;
0455          ];
0456   
0457  Scenic  -> "20-foot depression"
0458    with  name 'depression' 'dirt' 'twenty' 'foot' 'bare' '20-foot',
0459          description "You're standing in it.";
0460   
0461  Object  -> Grate "steel grate"
0462    with  name 'grate' 'lock' 'gate' 'grille' 'metal' 'strong' 'steel' 'grating',
0463          description "It just looks like an ordinary grate mounted in concrete.",
0464          with_key set_of_keys,
0465          door_dir [;
0466              if (location == Below_The_Grate) return u_to;
0467              return d_to;
0468          ],
0469          door_to [;
0470              if (location == Below_The_Grate) return Outside_Grate;
0471              return Below_The_Grate;
0472          ],
0473          describe [;
0474              if (self has open) "^The grate stands open.";
0475              if (self hasnt locked) "^The grate is unlocked but shut.";
0476              rtrue;
0477          ],
0478          found_in Below_The_Grate Outside_Grate,
0479    has   static door openable lockable locked;
0480   


Last updated 23 June 2004. This web site has not been fully supported since April 2008. Information may be out of date. This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.