Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing Toyshop.inf

Hand Grenade (lines 209-246)

209  ! >GR  A classic example of a timer (or, as some people call them and
210  !      appropriately so in this case, a fuse).  To demonstrate stopping
211  !      a timer before the alarm (and for fun), there is also a pin:
212  ! ----------------------------------------------------------------------------
213   
214  Object -> grenade "nasty-looking hand grenade"
215    with name "hand" "grenade" "nasty" "nasty-looking",
216         initial "A nasty-looking hand grenade (there is no other kind) 
217                  rolls about irresponsibly on the floor.",
218         description "Not recommended for children under 90.",
219         before
220         [; Pull: if (self has general) "Too late for that.";
221                StartTimer(self, 5); give self general;
222                move the_pin to player;
223                "You pull the pin out, an irrevocable act.";
224         ],
225         time_left 0,
226         time_out
227         [;  deadflag=1;
228             "^An immense explosion suddenly demolishes the toyshop!^^
229               Will you never learn?";
230         ],
231    has  transparent;
232   
233  Object -> -> the_pin "pin"
234    with name "pin",
235         description "The pin is designed to be easy to pull.",
236         before
237         [; Take, Pull: if (self in grenade) <<Pull grenade>>;
238            Insert:
239                if (self notin grenade && second==grenade)
240                {   StopTimer(grenade); move self to grenade;
241                    give grenade ~general;
242                    "Amazing!  You got the pin back into the grenade!";
243                }
244         ];
245   
246  ! ----------------------------------------------------------------------------


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.