Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing Balances.inf

4. Some multiple objects, coins in fact, coded in deluxe fashion: (lines 545-591)

0545  Attribute is_coin;
0546  Class Coin
0547    with name "coin",
0548         description "A round unstamped disc, presumably part of the local
0549             currency.",
0550         parse_name
0551         [ i j w;
0552           if (parser_action==##TheSame)
0553           {   if ((parser_one.&name)-->0 == (parser_two.&name)-->0) return -1;
0554               return -2;
0555           }
0556           w=(self.&name)-->0;
0557           for (::i++)
0558           {   j=NextWord();
0559               if (j=='coins') parser_action=##PluralFound;
0560               else if (j~='coin' or w) return i;
0561           }
0562         ],
0563    has  is_coin;
0564   
0565  Class GoldCoin
0566   class Coin,
0567    with name "gold",
0568         short_name "gold coin",
0569         plural "gold coins";
0570  Class SilverCoin
0571   class Coin,
0572    with name "silver",
0573         short_name "silver coin",
0574         plural "silver coins";
0575  Class BronzeCoin
0576   class Coin,
0577    with name "bronze",
0578         short_name "bronze coin",
0579         plural "bronze coins";
0580   
0581  SilverCoin players_coin;
0582   
0583  [ TossCoinSub; if (noun notin player) "You need to be holding the coin first.";
0584    move noun to parent(player);
0585    if (location==thedark) "You throw it away into the darkness.";
0586    if (random(20)==1)
0587       "You toss the coin, and it lands... on its edge, amazingly.";
0588    "You toss the coin, and it comes up... blank, since neither side is
0589     marked.";
0590  ];
0591   


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.