home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / rec / arts / intfict / 927 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  2.2 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!asuvax!ukma!netnews.louisville.edu!wkuvx1!mollems
  2. From: mollems@wkuvx1.bitnet
  3. Newsgroups: rec.arts.int-fiction
  4. Subject: Re: counters
  5. Message-ID: <1992Nov20.104535.4117@wkuvx1.bitnet>
  6. Date: 20 Nov 92 10:45:35 CST
  7. References: <1992Nov20.071549.19959@nevada.edu>
  8. Organization: Western Kentucky University, Bowling Green, KY
  9. Lines: 50
  10.  
  11. In article <1992Nov20.071549.19959@nevada.edu>, dalton@nevada.edu (William Turlough Cat) writes:
  12. > I need to be able to have an object count the number of times something is
  13. > done to it.  Specifically, I want to be able to use something for a certain
  14. > number of times.  I can't seem to find anything to do with counting except
  15. > in functions.
  16. > William Turlough Cat aka beiad
  17.  
  18. One possible solution to this (assuming you are using TADS, though the
  19. basic idea works no matter what you're doing) is to give the object an
  20. attribute called STATE.  Then, each time it's used, the object's state
  21. is increased by one.  For example, if you had a magic wand with three
  22. charges, which was used by waving it, you could do the following:
  23.  
  24. magicwand : item
  25.     noun = 'wand'
  26.     adjective = 'magic'
  27.     sdesc = "magic wand"
  28.     thedesc = "the magic wand"
  29.     ldesc = "The wand is really nifty; it's got lots of little
  30.     stars and planets embossed on it, with some sharp gold trim.
  31.     A label on the side of the wand proclaims it to be the
  32.     \"Acme Dam Yooseful Magik Cheez (tm) Phrodukshun Devyse.\""
  33.     state = 0
  34.     verDoWave (actor) =
  35.     {
  36.         if (self.state = 3) 
  37.             "Waving the wand produces a tiny droplet of
  38.             Cheez (tm), but nothing more.";
  39.     }
  40.     doWave (actor) =
  41.     {
  42.         self.state := self.state + 1;
  43.         "You wave the wand, and the tip begins to glow
  44.         brightly.  Suddenly, there is a loud rushing noise
  45.         which sounds like a freight train, and a torrent of
  46.         Cheez (tm) comes gushing from the wand, covering
  47.         everything in the area (including yourself).";
  48.     }
  49. ;
  50.  
  51. Thus, the first time you wave the wand, its state becomes one, the
  52. second time, two, the third time, three, and the fourth time it gets
  53. caught by the verDoWave potion of the item definition.
  54.  
  55. Sean
  56. ---
  57. M. Sean Molley, CS Department, Western Kentucky University
  58. .sig is currently in the shop for 30,000 line tune-up and maintenance
  59.  
  60.