/
/***********************************************************
*  This color code is based somewhat on Lopes color.      *
*  The big difference is I'm using tables for the colors  *
*  and custom color spots. If you already have Lopes      *
*  color installed, you should be able to install this    *
*  with minimal difficulty. Read the README.color file    *
*  included with this package for ROM installation        *
*  instructions. Please send bugs/fixes/comments to:      *
*  jessechoward@netscape.net                              *
*  This is just a development release so if something is  *
*  missing or you would like to see something in the next *
*  release, e-mail me and I will try to get it done.      *
***********************************************************/
/*******************
* Color V1.0.1    *
* by Thanos for   *
* Carpathia MUD   *
* kyndig.com 9501 *
*******************/

This is the installation text for installing this color code on
a ROM2.4 based MUD. If you have any problems, e-mail me at the
above address.

Since I did this instead of Lopes color, I am assuming Lopes is
NOT installed. You should be able to figure out what needs to be
done if Lopes is already installed.

****************************************************************
Start here
****************************************************************
1. install color.c and color.h into the src directory
2. insert color.o into the Makefile
3. Add the following to merc.h

/*
 * Add this ACT flag in the rest.
 * I used B but use any open ACT flag if B isn't available
 */
#define PLR_COLOR               (B) /* color */

/* 
 * Add this line to pc_data.
 * make sure you take out Lopes color variables
 * if Lopes is already installed
 */
   long                colors[MAX_CUSTOM_COLORS]; /* color Thanos */

4. in comm.c add the following:

/***with the rest of the includes right after merc.h add:***/
#include "color.h"

/***in init_descriptor (the unix one)***/
// add/change variable at the top:

char buf[MAX_STRING_LENGTH*2];

// change this so we can see color in the greeting
  /*
   * Send the greeting.
   */
   {
       extern char * help_greeting;

       color_convert( NULL, (const char*)help_greeting, buf );

       if ( help_greeting[0] == '.' )
           write_to_buffer( dnew, buf+1, 0 );
       else
           write_to_buffer( dnew, buf, 0 );
   }


/***in bust_a_prompt***/
// add new variable at top

char buffer[MAX_STRING_LENGTH*2];

// change the end of the function to look like this before it returns
     ++str;
     while( (*point = *i) != '\0' )
        ++point, ++i;
  }
/*
* write_to_buffer( ch->desc, buf, point - buf );
* color comment Thanos
*/
  *point       = '\0';
  color_convert( ch, buf, buffer );
  send_to_char( "{P", ch );
  write_to_buffer( ch->desc, buffer, 0 );
  send_to_char( "{x", ch );

  if (ch->prefix[0] != '\0')
    write_to_buffer(ch->desc,ch->prefix,0);

  return;
}

/***change send_to_char to look like this***/

void send_to_char( const char *txt, CHAR_DATA *ch )
{
   char buffer[MAX_STRING_LENGTH*2];

   if ( txt != NULL && ch->desc != NULL )
   {
       color_convert( ch, txt, buffer );
       write_to_buffer( ch->desc, buffer, 0 );
   }

   return;
}

/***change page_to_char to look like this***/

void page_to_char( const char *txt, CHAR_DATA *ch )
{
   char buffer[MAX_STRING_LENGTH*4];

   if ( txt == NULL || ch->desc == NULL)
       return;

   color_convert( ch, txt, buffer );

   if (ch->lines == 0 )
   {
       send_to_char(buffer,ch);
       return;
   }

#if defined(macintosh)
       send_to_char(buffer,ch);
#else
   ch->desc->showstr_head = alloc_mem(strlen(buffer) + 1);
   strcpy(ch->desc->showstr_head,buffer);
   ch->desc->showstr_point = ch->desc->showstr_head;
   show_string(ch->desc,"");
#endif
}


/***in act_new make sure you have these variable***/
   char *point;
   char *pbuf;
   char buffer[MAX_INPUT_LENGTH*2];

/***change the end of act_new to look like this***/

      *point++ = '\n';
      *point++ = '\r';
      *point   = '\0';
      buf[0]   = UPPER(buf[0]);
      pbuf    = buffer;
      color_convert( to, buf, pbuf );
      write_to_buffer( to->desc, buffer, 0 );

   }

   return;
}


/*** Thats it for comm.c ***/


5. somewhere in interp.h
/***interp.h***/
DECLARE_DO_FUN( do_color );

6. somewhere in the command table in interp.c
/***interp.c***/
{ "color",          do_color,       POS_DEAD,        0,  LOG_NORMAL, 1 },

7. in save.c add the following

/*** in fwrite_char pick a good spot and insert the following line ***/
// if you have lopes.. remove his color saving stuff too.

// I did mine right before it saves the act_flags
  save_char_color( ch, fp ); /* color */

/*** in load_char_obj right after you initialize the title ***/
// and before the sats

   ch->pcdata->title                   = str_dup( "" );

   /* set default colors. Thanos */
   reset_colors( ch );

   for (stat =0; stat < MAX_STATS; stat++)
       ch->perm_stat[stat]             = 13;

/*** in fread_char ***/
// find the case 'C': spot 
// and right after you read the comm flags but before case 'D':
           KEY("Comm",         ch->comm,               fread_flag( fp ) );

           if ( !str_cmp( word, "Colors" ) )
           {
               load_char_colors( ch, fp );
               fMatch = TRUE;
               break;
           }

           break;

       case 'D':

/*** end of save.c ***/
****************add a help file*************************************
Last but not least: copy and paste this into your favorite help file

0 COLOR COLOUR~
Color is original code by Thanos. NOT Lope! But thanks for the concept.

{BCOLOR{x by itself toggles color on or off.
{BCOLOR {yON/OFF{x turns color on or off.
{BCOLOR {yHELP{x will display all available colors and their tags.
{BCOLOR {ySHOW{x will display all available color fields for you to set.
{BCOLOR SET {y[FIELD] [COLOR]{x will set the fields color.

examples:
color help
color show
color set hp green
color set mana bright magenta
say the sky is {{Bbright blue{{x.

Be sure to remember to use {{x to end your color or it might bleed
into other lines.
~


********************************************************
ADDING COLORS to channels
********************************************************
I am sure you can figure this out.
Heres an example. The custom letter for the immortal channel is "I".
for when it goes to the person:
act_new("[$n]: {I$t{x",ch,argument,NULL,TO_CHAR,POS_DEAD);
for when it goes to the erst of the people in the loop:
act_new("[$n]: {I$t{x",ch,argument,d->character,TO_VICT,POS_DEAD);

********************************************************
ADDING NEW CUSTOM COLORS
********************************************************
To add a new custom color.. just add a define for it in color.h
and increase the MAX_CUSTOM_COLORS and add the appropriate entry
in the custom_color_table. Make sure you don't re-use a letter.

You can use strip_ansii to strip color from a string. I recomend
doing this on channels or areas you don't want people adding their own
flare to. You can also use strip_ansii to get a strlen that excludes
color codes.

********************************************************
KNOWN ISSUES
********************************************************
1. I didn't add a bell. Why? cus its annoying.

2. the w and the l get mixed up because in Lopes
   the l is the w, but l is light gray. I was confused
   by this so I changed it more to my liking.

3. If you have Lopes color you will lose all of your
   saved color things in  your pfiles cus I didn't make
   it compatable. I used fwrite_flag to save the colors
   because it seemed more inutitive to me.

4. Also if Lopes is already installed you will have to
   add all of the letters for things that are missing
   into color.h and the custom_color_table for them to work.

5. I have had some funky things happen regarding color_convert
   because I allow a NULL ch to be sent to it. I think I have
   fixed them but you never know.


Have fun. If you find any of this useful I would apreciate
an e-mail at jessechoward@netscape.net.

Thanos of Carpathia MUD @ darktorment.kyndig.com 9501