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 }
Then:
} spec_to_name[] = {
SPEC_NAME(baker),
SPEC_NAME(receptionist),
...etc...
};
>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))
break;
if (spec_to_name[i].spec_name == NULL) {
send_to_char("ack and stuff.\r\n", ch);
return;
}
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 mouse.van.ml.org.
--
George Greer, greerga@circlemud.org | Genius may have its limitations, but
http://mouse.van.ml.org/ (mostly) | stupidity is not thus handicapped.
http://www.van.ml.org/CircleMUD/ | -- Elbert Hubbard
+------------------------------------------------------------+
| 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