G'Day all. I wanted to add a re-roll function in the Nanny() function. I added it fine (after hours of trying to figure out STATE and all this other stuff, but I REALLY REALLY don't like MY OWN CODE. ** I had to use two *GOTO* statements, and i don't want to (bad programming practice ... **** Any helps would be appreciated. Jussy. NOTE : The code DOES run fine. NOTE 2 : I sorta cannot understand the STATE thingy. As far as I know / understand, it checks the roots of the program for the current state it's in (like a Finite State machine or something). And if it's not connected it goes back to the last state until it gets out of nanny (ie connected and playing). But in that loop, it also waits for a user input, which is something I DON'T want. anyways .. here's my code .. Good Luck! and thanks in advance for any helpful idea's ----------8< snip snip >8--------------- <in interpreter.c .. in the nanny function ..> ... case CON_QRACE: int_arg = atoi (arg); // This converts the string to an integer value. load_result = parse_race(int_arg); if (load_result == RACE_UNDEFINED) { SEND_TO_Q("\nThat is an Invalid Race ... *sigh*\n", d); SEND_TO_Q("Ok .. Now lets try that again ...\n",d); return; } else { GET_RACE(d->character) = load_result; } // Now lets roll the players abilities. // Jus - 12/10/96 goto forced_to_do_con_rolls; //STATE(d) = CON_ROLLS; // If i use the STATE .. then i waits for the player to give some input, which i // don't want ... break; case CON_ROLLS : forced_to_do_con_rolls: // Unwanted Label added here .. out of necessity =(. // This is case statement for controlling the players ability to choose // their characters ability rolls. // Jus - 12/10/96 //Ok. Lets create a new character. if (!GET_LEVEL(d->character)){ do_start_I(d->character); // Rolls the die } sprintf (buf, "\nCharacter's Rolls -: \n"); // <blahblahblahblah .. lots of sprintf's with ability rolls> send_to_char(buf, d->character); // Test for valid classes. // This function just determins what classes are available to the player, dependant // upon RACE and ROLLS (they are displayed to the screen) parse_class_II(d->character); SEND_TO_Q("Please type [Y]es to re-roll, [R]ace to select another race,\n" "[Q]uit to Wimp out or any other key to *accept* these rolls and\n" "continue... [Y/R/Q]:-", d); STATE(d) = CON_CLASS_CHECK; break; // This Checks to see if the user wants to continue or not. case CON_CLASS_CHECK: switch (*arg) { case 'Y' : case 'YE' : case 'YES' : case 'y' : case 'ye' : case 'yes' : case 'Yes' : send_to_char ("Ok. Re-rolling your character ...", d->character); d->character->player.level = 0; goto forced_to_do_con_rolls; // I DON'T WANT THAT GOTO ADDED HERE ALSO, but i need it .. =( break; case 'Q' : case 'q' : case 'quit' : case 'Quit' : send_to_char ("\nFair Enough .... WIMP! Have fun in reality ...\n\n", d->character); close_socket(d); break; case 'R' : case 'r' : case 'race' : case 'Race' : SEND_TO_Q(race_menu, d); SEND_TO_Q("\nWhich Race do you wish to select ? :", d); STATE(d) = CON_QRACE; break; default : SEND_TO_Q(class_menu, d); SEND_TO_Q("Please Select a Class :-", d); STATE(d) = CON_QCLASS; break; } break; case CON_QCLASS: etc etc etc etc .. thanks and good luck. +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST