Replacing CON_ states with functions:
On a recent project in which I built a very bare-bones
MUD (about 2500 lines), instead of using CON_ states
I gave descriptors a pointer to a parser function which
is passed their input once they issue a command. I found
this to be much cleaner than the nanny() function.
Here is a sample (its in c++)
PARSER(getname){
if(findchar(input, 0, 1))
desc->write("That name has already been used, try another: ");
else{
((creation_data *) desc->storage)->name = strdup(input);
desc->prompt("Enter a password for your character: ", getpw, NULL);
}
}
PARSER(getpw){
((creation_data *) desc->storage)->password = strdup(input);
desc->prompt("Please confirm the password for your character: ", confpw,
NULL);
}
PARSER(confpw){
if(strchk(((creation_data *) desc->storage)->password, input))
desc->prompt("Choose a gender for your character (male or female): ",
getgender, NULL);
else{
delete ((creation_data *) desc->storage)->password;
desc->prompt("Passwords do not match. Enter a password for your
character: ", getpw, NULL);
}
}
Ugh code looks ugly in this email prog.
Sorry if it's over 75 chars, Juno email program is bad bad bad
So, the question is, would such a system be
good for circle (It can also be used to make
OLC much cleaner!)
Blaize
Note: if replying to second part of message, you should
rename Subject probably :P
--
+---------------------------------------------------------------+
| FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
| Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
| Newbie List: http://groups.yahoo.com/group/circle-newbies/ |
+---------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 06/25/03 PDT