Alrightly here. I've been working on some hair color code. I am trying a few 
different ways to put this in. Since I am trying to teach myself a lot of 
stuff, and different ways of doing things, I have deicded to try to use other 
files for this.
I shall explain what I have done.
I have created a file called hair.c
In it, it will hold the part of the code that will print the hair color 
options (based on race) to the screen.
Here is the code:

void human_hair( CHAR_DATA *ch )
{
        stc( "<><> Possible Human Hair Colors <><>\n\r", ch );
        stc( "{c[{W1{c] {yBrown{x\n\r", ch);     
      stc( "{c[{W2{c] {yDark Brown{x\n\r", ch );
          stc( "{c[{W3{c] {yLight Brown{x\n\r", ch );
        stc( "{c[{W4{c] {yHoney Brown{x\n\r", ch );
        stc( "{c[{W5{c] {yChestnut Brown{x\n\r", ch );
        stc( "{c[{W6{c] {DRaven{x\n\r", ch );
}
That part works.
In comm.c, this is the code that contains that:
case CON_GET_NEW_HUMAN_EYE:

{
    eye color code blah blah blah
}

        human_hair(ch);
            d->connected = CON_GET_NEW_HAIR;
            break;
^ last thing in the case statement.
That works. It prints to the screen fine.
This is what I have in case CON_GET_NEW_HAIR: (and where the problems start). 
I only did two races, to see if this would work.
 if (ch->race == race_lookup("human"))
         {
               human_select(ch, argument);
        }
  if (ch->race == race_lookup("elf"))
         {
               human_select(ch, argument); (Just some testing again)
        }
}
 write_to_buffer( d, "\n\r\n\rWhat is your sex (M/F)?\n\r",0);
            send_to_desc("{wYour choice or HELP for more info:{x\n\r",d);
            d->connected = CON_GET_NEW_SEX;
            break;


Then, in hair.c, for human_select, I have this:
void human_select( CHAR_DATA *ch, char* argument)
{
switch ( argument[0] )
{
 case '1':
         stc( "Your hair color is now brown.\n\r", ch);
         ch->pcdata->hair = HAIR_BROWN;
         break;

 case '2':
         stc( "Your hair color is now dark brown.\n\r", ch);
         ch->pcdata->hair = HAIR_DARK_BROWN;

    default:
         stc ("Thats not a correct hair color.\n\r", ch);
         return;

}


}

The top of hair.c looks like:
#if defined(macintosh)
#include <types.h>
#else
#include <sys/types.h>
#include <sys/time.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include "merc.h"
#include "recycle.h"


In merc.h, I have this:
void    human_hair      args( ( CHAR_DATA *ch ) );
void    human_select    args( ( CHAR_DATA *ch, char* arguement ) );


This code works fine, ONLY if they pick something on the list. If they choose 
say, 3, it will print, its not a correct eye color, then go back to sex. I 
have tried MANY things to try and get it to loop back, but I can't figure it 
out. I asked numerous people, and worked on it  most of the evening last 
night, and tonight. I know its due to my lack of experience, but I am trying 
to learn. 
Thanks.

Reply via email to