Lot of newbie players ask me something like "why can't I buy item by number in shop?" and I got tired of telling them to type "buy #3" instead of "buy 3". Now I changed shops slightly so commands like "buy 3" could be accepted. Here is code snippet. It seems to work perfectly: even commands like "buy 5 3" work correctly: character bought 5 pieces of #3 in list. The snippet: ------------------------------------------------------------------------- First, cut out the transaction_amt function and replace in with this one: ------------------------------------------------------------------------- int transaction_amt(char *arg) { int num; char *arg_rem; arg_rem = one_argument(arg, buf); if (*buf) if ((is_number(buf))) { if (*arg_rem) { num = atoi(buf); strcpy(arg, arg + strlen(buf) + 1); return (num); } } return (1); } ------------------------------------------------------------------------- In get_hash_obj_vis function look for: ------------------------------------------------------------------------- if (is_number(name + 1)) index = atoi(name + 1); else return (0); ------------------------------------------------------------------------- And replace it with: ------------------------------------------------------------------------- if (is_number(name)) index = atoi(name); else if (is_number(name + 1)) index = atoi(name + 1); else return (0); ------------------------------------------------------------------------- In function get_purchase_obj look for: ------------------------------------------------------------------------- do { if (*name == '#') obj = get_hash_obj_vis(ch, name, keeper->carrying); ------------------------------------------------------------------------- And replace it with: ------------------------------------------------------------------------- do { if (*name == '#' || is_number(name)) obj = get_hash_obj_vis(ch, name, keeper->carrying); ------------------------------------------------------------------------- Done. Andrey (andrey@alex-ua.com) aka Zmey//RMUD +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST