Re: [CODE] Attempt at remove all items from container, left obj->contains endless!!

From: Patrick Dughi (dughi@imaxx.net)
Date: 05/01/99


> I'm trying to remove all items from a container (its a ITEM_WEAPON) but that
> doesn't matter really... player can't do remove obj from weapon... its only
> internal, I'm hiding objects inside the weapons contains...
>
> I know there is a way to do this easily, but I just haven't figured it out
> yet, could someone direct me on the right path to removing all objects from
> a container (without knowing what objects are in there, so a loop I mean =)
>
        struct obj_data *secondary,*tertiary;
        struct obj_data *obj=GET_EQ(ch,WEAR_WIELD);

        if(!obj) {
          send_to_char("You don't see that here.\r\n",ch);
          return;
        }
        if(!(secondary=obj->contains)) {
          send_to_char("Nothing in there.\r\n",ch);
          return;
        }
        while(secondary) {
          tertiary=secondary->next_content;
          obj_from_obj(secondary);
          obj_to_char(secondary,ch);
          sprintf(buf,"You get a %s from the %s.\r\n",
                secondary->short_description,
                obj->short_description);
          send_to_char(buf,ch);
          secondary=tertiary;
        }
        send_to_char(OK,ch);

                Don't forget some objects may have no short descriptions,
and other checks of that sort, but that ought to get you going.

                                                        PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



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