Newsgroups: rec.arts.int-fiction
Path: nntp.gmd.de!Dortmund.Germany.EU.net!Germany.EU.net!howland.reston.ans.net!vixen.cso.uiuc.edu!usenet.ucs.indiana.edu!news.cs.indiana.edu!shulick@kiwi.ucs.indiana.edu
From: "Sam Hulick" <shulick@kiwi.ucs.indiana.edu>
Subject: Inform: A gift (safe.inf)
Message-ID: <1995Sep6.110418.26596@news.cs.indiana.edu>
Organization: Vallen Software
Date: Wed, 6 Sep 1995 11:04:13 -0500
Lines: 86


I was bored, so I whipped up some sorta neat code.  It's a safe, and
implements a dial (as someone previously asked about) which will open
the safe when you use the right combination (three numbers, each from
1-50).  Feel free to use this code for anything you want.  Enjoy!

! safe.inf -- an experiment
Switches v5x;

Constant Story "CRACK THE SAFE";
Constant Headline "^An Interactive Safe-Cracking^Freely distributable.^";
Constant MAX_SCORE 5;

Include "parser";
Include "verblib";

Property set1;
Property set2;
Property setthis;

Object richroom "Dr. Dork's Apartment"
 with  description "The moonlight pours through Dr. Dork's apartment \
                    window, giving you enough light to see the dial of \
                    the huge safe in front of you.  There is no way \
                    out, except IN to that safe! (Use ~set dial to X~ \
                    to turn it to a certain number between 1 and 50.)",
       cant_go "Just work on the safe."
 has   light;

Object thesafe "thick steel safe" richroom
 with  name "steel" "safe",
       description [;
          print "It's a medium-sized safe, with extremely thick \
                 steel and the typical combination dial on it.  \
                 The dial is currently set to ";
          EnglishNumber(dial.setthis); ".";
       ],
       before [;
        Take: "You're not really interested in a hernia.";
       ],
 has   static transparent openable locked;

Nearby dial "dial"
 with  name "dial",
       description [;
          print "The dial to the safe is currently set to ";
          EnglishNumber(self.setthis); ".";
       ],
       set1 0, set2 0, setthis 1,
       before [;
        SetTo: if (special_number < 1 || special_number > 50)
                 "The dial only goes from 1 to 50.";

               ! Rotate numbers...
               self.set1 = self.set2;
               self.set2 = self.setthis;
               self.setthis = special_number;
               print "You turn the dial to ";
               EnglishNumber(self.setthis); print ".^";

               if (self.set1 == 28 && self.set2 == 7 &&
                   self.setthis == 20)
               {
                  give thesafe ~locked;
                  score = MAX_SCORE;
                  deadflag = 2;
                  print "You hear a click!  You anxiously open the \
                         safe, and run off with Dr. Dork's box of \
                         Froot Loops.^";
               }
               rtrue;
       ];

[ Initialise;
   location = richroom;
   "^^^^You're poor and desperate, so it's time to...^^^^";
];

Include "grammar";
end;

-- 
--- Sam Hulick ------------- shulick@indiana.edu ---------------------
Systems Consultant        | Homepage:
Indiana College Placement |    http://copper.ucs.indiana.edu/~shulick/
  and Assessment Center   | PGP public key available on request
