[Circle] Newbie: Spec O code

From: Brad Freshour (monocirc@telepath.com)
Date: 11/18/96


I got a snippet of code for a coke machine and was just messing around with
it. How do you tell the code which object number it's for?  Hears the code,
and I have 1200 as the coke dispenser and 1201 as the coke can.. 

CODE:  by: Sliver
--
SPECIAL(pop_dispenser)
{
 struct obj_data *obj = me, *drink;
 int give_coke = 1206; /* Vnum of the can of coke */
 if (CMD_IS("list"))
     {
     send_to_char("To buy a coke, type 'buy coke'.\r\n", ch);
     return (TRUE);
     }
 else if (CMD_IS("buy")) {
          if (GET_GOLD(ch) < 25) {
          send_to_char("You don't have enough gold!\r\n", ch);
          return (TRUE);
          } else {
            drink = read_object(give_coke, VIRTUAL); 
            obj_to_char(drink, ch);
            send_to_char("You insert your money into the machine\r\n",ch);
            GET_GOLD(ch) -= 25; /* coke costs 25 gold */
            act("$n gets a pop can from $p.", FALSE, ch, obj, 0, TO_ROOM);
            send_to_char("You get a pop can from the machine.\r\n",ch);
          }
          return 1;
 }
 return 0;
}
--
Thanks

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST