Re: [Code] ASSIGNMOB() function

From: George (greerga@CIRCLEMUD.ORG)
Date: 10/19/98

On Fri, 16 Oct 1998, Roger Smith wrote:

>I would like to know how to assign a spec to a mob using a command
>online, but I haven't had any success.
>For example: assignmob 1200 receptionist
>I don't know how exactly to convert a char into a SPECIAL().

struct {
  const char *spec_name;
  special_function_pointer_thingie *func;
} spec_to_name[] = {
  { "baker", baker },
  { "receptionist", receptionist },
  { "guard", guard };
  { NULL, NULL }

Or if you think that is redundant:
#define SPEC_NAME(x)    { #x, x }

} spec_to_name[] = {

>Basically I'm asking:
>How do I turn "receptionist" into SPECIAL(receptionist) without using a
>lot of if-statements?

for (i = 0; spec_to_name[i].spec_name != NULL; i++)
  if (!str_cmp(chopped_argument_here, spec_to_name[i].spec_name))

if (spec_to_name[i].spec_name == NULL) {
  send_to_char("ack and stuff.\r\n", ch);

Function can be used as 'spec_to_name[i].func'.

John Evans made up something like this to fix the "Mob-Spec: Exists" line
on the stat function to actually print the name of the special procedure.
His patch will be on

George Greer, | Genius may have its limitations, but   (mostly) | stupidity is not thus handicapped.    |                  -- Elbert Hubbard

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

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