On Tue, 12 Jan 1999, Anthony Benjamin wrote:
> What I would like to do, is have do_eat, check the inventory for food of
> any kind, if someone types eat all, instead of saying "You don't have
> all." I would like it to say a message similar to.. You cannot eat a
> sword, You cannot eat a shield, for items it finds in the inventory that
> are unedible, but i would like it to eat stuff it finds that are edible
> in the inventory....So...i was wondering if i was ontrack with the
> following modifications...
>
> if (!(food = get_obj_in_list_vis(ch, arg, ch->carrying))) {
> sprintf(buf, "You don't seem to have %s %s.\r\n", AN(arg), arg);
> send_to_char(buf, ch);
> return;
>
> if(arg = "all" || "ALL"){
A couple of points. First, you can't compare a string like you would an
int, you need strcmp(), str_cmp() or something similar. Second, you
aren't checking for equivalence at all in the above example. That is
checked with the == operator. The = operator is used to assign a value to
a numeric or pointer variable. Third, CircleMUD is written in C, not C++.
So...
if (!str_cmp(arg, "all") { /* str_cmp() is case insensitive */
send_to_char("You can only eat one thing at a time.\r\n", ch);
return;
}
That is the easy way to do it, it sounds like you want to loop through the
players inventory and send a message for each item. I wouldn't recommend
that personally, but if you want to, look through the code for a place
where it already does what you want and copy it.
"Misery is boundless"
-Xual the Torturer, on the Eve of the Sundering.
Danathara Online RPG
telnet://danathara.ml.org:4000
+------------------------------------------------------------+
| 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