Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing Toyshop.inf

Helium Balloon (lines 105-146)

105  ! >HE  The balloon is completely self-contained as a piece of code, except
106  !      that it does not set itself going (though even this could have been
107  !      arranged): it is set going in the Initialise() routine.
108  !
109  !   Notice that the "after" for Drop takes away the "moved" attribute.
110  !   This is one way to ensure that the "initial" message will always be
111  !   the one displayed.  (Alternatively, we could have given it a "describe"
112  !   property.)
113  ! ----------------------------------------------------------------------------
114   
115  Object -> balloon "helium balloon"
116    with description "Blue, with a yellow smile.",
117         name "helium" "balloon" "blue" "string",
118         initial "A balloon nestles on the ceiling, its long string hanging.",
119         before
120         [; Attack: remove self; StopDaemon(self);
121                  "Easily, you burst the balloon. Pop!^^
122                   Shame it was irreplaceable, really.";
123         ],
124         after
125         [; Take: "You take the balloon by its string. It's buoyant!";
126            Drop: give balloon ~moved;
127                  "The balloon rises gracefully to the ceiling.";
128         ],
129         daemon
130         [ from_room to_room;
131            if (random(3)~=1) rfalse;
132            from_room=parent(self);
133            if (from_room==East_End or West_End) to_room=Toyshop;
134            if (from_room==Toyshop)
135            {   if (random(2)==1) to_room=East_End;
136                else to_room=West_End;
137            }
138            if (to_room==0) rfalse;
139            move self to to_room;
140            if (location==from_room)
141              "^A breeze blows the balloon away to the ", (name) to_room, ".";
142            if (location==to_room)
143              "^A breeze blows the balloon in from the ", (name) from_room, ".";
144         ];
145   
146  ! ----------------------------------------------------------------------------


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.