Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing Toyshop.inf

Little Red Car (lines 147-187)

147  ! >CA  There are two exceptions to the ordinary before/after rules, for
148  !      vehicles and things which can be pushed from place to place: this car
149  !      demonstrates both at once.
150  !
151  !   The "before" for PushDir (push in a named direction) must call
152  !   AllowPushDir and then return true to signify that the push is legal.
153  !
154  !   The "before" for Go must return true to signify that travelling in
155  !   the object is legal.  (Note that it must also be enterable.)
156  ! ----------------------------------------------------------------------------
157   
158  Object -> car "little red car"
159    with name "little" "red" "car" "kar1",
160         description "Large enough to sit inside. Among the controls is a 
161                   prominent on/off switch. The numberplate is KAR 1.",
162         when_on  "The red car sits here, its engine still running.",
163         when_off "A little red car is parked here.",
164         before
165         [; PushDir: AllowPushDir(); rtrue;
166            Go: if (car has on) { Achieved(1); "Brmm!  Brmm!"; }
167                print "(The ignition is off at the moment.)^";
168         ],
169         after
170         [; PushDir: "The car rolls very slowly as you push it.";
171         ],
172    has  switchable enterable static container open;
173   
174  Object -> -> "small note"
175    with name "small" "note",
176         description
177             "  !!!! FROBOZZ MAGIC CAR COMPANY !!!!^
178             ^Hello, Driver!^
179             ^Instructions for use:^
180             ^Switch on the ignition and off you go!^
181             ^Warranty:^
182             ^This car is guaranteed against all defects for a period of 
183              76 milliseconds from date of purchase or until used, 
184              whichever comes first.^
185             ^Good Luck!";
186   
187  ! ----------------------------------------------------------------------------


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.