Re: Newbie? Half_Chop (Casting syntax)

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 08/16/98

On Sun, 16 Aug 1998, Brett Williams wrote:

->Should I do it something like that or is there an easier method? do/while loop
->perhaps? I looked at the msg in about language word for word, and it had a
->parser but I'm not sure if thats what I'm looking for. Any help on this matter
->would be greatly appreciated, I'm not used to these functions. Thanx..

This isn't as hard as it might seem. The way we discussed it on the
list a while back (without the "at" part, just "cast my spell name
here target") was a bit harder and I think (emphasis on "think") that
some code came about because of it, so you might want to check the
archives. At the very least it was discussed in detail.

Anyway, on to your particular dilemna; splitting at the word "at".

  char spell_name[MAX_INPUT_LENGTH];
  char target_name[MAX_INPUT_LENGTH];

  *spell_name = '\0';
  argument = one_argument(argument, arg);

  while (*arg && str_cmp(arg, "at")) {
    strcat(spell_name, arg);
    argument = one_argument(argument, arg);

  if (!*spell_name) {
    send_to_char("Cast what?\r\n", ch);

  if (*arg)
    argument = one_argument(argument, target_name);

  if (!*target_name) {
    send_to_char("Cast the spell at who?\r\n", ch);

You can also do this with strstr() and some fun string manipulation.
I'll leave that as an exercise to the reader, though.

-dak : As always, this is Mailer Code(tm), no guarantees attached.

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

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