I'm trying to write something in right now that asks you for your choice of hair color, style, eye color, and skin tone.
I've written in some code in nanny that prompts for it and it will set the variable for that log in.
I added something to mset that allows you to set that on a PC as well,
which works fine. I added to the look command (took out the crappy ch->description nonsense) to show character hair and
eye color. All of that stuff work fine. However i can't figure out what i need to add to the save.c file to get it to
save the value. I added something into the fwrite_char that actually writes Hair Color into the player file and sets
it's value to the hairc variable i declared for players in CHAR_DATA. fwrite_char looks like this:
USA
#1
#2
USA
#3
I've written in some code in nanny that prompts for it and it will set the variable for that log in.
I added something to mset that allows you to set that on a PC as well,
which works fine. I added to the look command (took out the crappy ch->description nonsense) to show character hair and
eye color. All of that stuff work fine. However i can't figure out what i need to add to the save.c file to get it to
save the value. I added something into the fwrite_char that actually writes Hair Color into the player file and sets
it's value to the hairc variable i declared for players in CHAR_DATA. fwrite_char looks like this:
fprintf( fp, "HairColor %d\n", ch->hairc );
[\code]
if i write something into bool load_char_obj it seems to just set the "default". rather than starting at the first element
of the array it will start at whatever integer i set. Anyone know what and where i need to add code?
Its in fread_char. I used the prefix p for all of them so they all went in the same case. Here is what I have:
You can see I have a few more then just hair. Anyways, just follow the example above for each or just save them all as I did.
Also, you might want to add a few functions such as these (if you used array's to keep the names of your data in, which is what I'm guessing you did)
Of course you change the if checks. Such as if you had 10 hair colors it would be if ( ch->phair < 10 ). You would most likely need to change the table name and the character variable its referring to. Good luck.
case 'P':
KEY( "Phair", ch->phair, fread_number( fp ) );
KEY( "Peye", ch->peye, fread_number( fp ) );
KEY( "Pheight", ch->pheight, fread_number( fp ) );
KEY( "Pbuild", ch->pbuild, fread_number( fp ) );
You can see I have a few more then just hair. Anyways, just follow the example above for each or just save them all as I did.
Also, you might want to add a few functions such as these (if you used array's to keep the names of your data in, which is what I'm guessing you did)
char *get_hair( CHAR_DATA *ch)
{
if ( ch->phair < 7)
return ( capitalize( hair_name[ch->phair] ) );
return ("Black");
}
char *get_eye( CHAR_DATA *ch)
{
if ( ch->peye < 8)
return ( capitalize( eye_name[ch->peye]) );
return ("Brown");
}
char *get_build( CHAR_DATA *ch)
{
if ( ch->pbuild < 6)
return ( capitalize( build_name[ch->pbuild] ) );
return ("Muscular");
}
char *get_height( CHAR_DATA *ch )
{
if ( ch->pheight < 4 )
return ( capitalize( height_name[ch->pheight] ) );
return ( "Tall" );
}
Of course you change the if checks. Such as if you had 10 hair colors it would be if ( ch->phair < 10 ). You would most likely need to change the table name and the character variable its referring to. Good luck.
Thanks, it looked to me like i needed to write a little chunk in the fwrite function
to actually write the variable into the pfile as well is
that necissary?
to actually write the variable into the pfile as well is
that necissary?
Yes. You need to write it into fwrite_char.