Renx writes "With this snippet you can make it possible to use manual color codes everywhere in the code or even in the game. It will replace the codes to the according ANSI codes right in the write_to_output() function so basically the new codes can be used almost everywhere. The file is also at: color.txt. Add this right before the function write_to_output() in comm.c: #define COLOR_ON(ch) (!IS_NPC(ch) ? (PRF_FLAGGED((ch), PRF_COLOR_1) ? 1 : 0) + \ (PRF_FLAGGED((ch), PRF_COLOR_2) ? 2 : 0) : 0) /* Color replacement arrays. Renx -- 011100 */ #define A "\x1B[" const char *ANSI[] = { "&", A"0m",A"0;30m",A"0;34m",A"0;32m",A"0;36m",A"0;31m", A"0;35m",A"0;33m",A"0;37m",A"1;30m",A"1;34m",A"1;32m",A"1;36m",A"1;31m", A"1;35m",A"1;33m",A"1;37m",A"40m",A"44m",A"42m",A"46m",A"41m",A"45m", A"43m",A"47m",A"5m",A"4m",A"1m",A"7m" ,"!"}; #undef A const char OUR[] = "&ndbgcrmywDBGCRMYW01234567luoe!"; To the header of function write_to_output(), add the following variables: int j; const char *i = NULL; char lbuf[MAX_STRING_LENGTH], *buf; Now, in function write_to_output(), search for following line: size = strlen(txt); and add all following right before that line: /* Color codes replacement cycle. Renx -- 011100 */ if (t->character != NULL) { buf = lbuf; for (;;) { if (*txt == '&') { txt++; for (j = 0; OUR[j] != '!'; j++) if ((*txt) == OUR[j]) { i = ANSI[j]; break; } if (!COLOR_ON(t->character)) i = ""; if (OUR[j] == '!') { i = "&"; txt--; } while ((*buf = *(i++))) buf++; txt++; } else if (!(*(buf++) = *(txt++))) break; } txt = lbuf; } That should cause all color codes starting with & being replaced with according ANSI codes. Colors are: &n - normal &d - black &D - gray &0 - background black &b - blue &B - bright blue &1 - background blue &g - green &G - bright green &2 - background green &c - cyan &C - bright cyan &3 - background cyan &r - red &R - bright red &4 - background red &m - magneta &M - bright magneta &5 - background magneta &y - yellow &Y - bright yellow &6 - background yellow &w - white &W - bright white &7 - background white Extra codes: &l - blink &o - bold &u - underline &e - reverse video && - single & << Meeting snippet [by Crimson] | Reply | View as text | Threaded | FTP Uploads 2000/2/22 >>
|
|
|
Helpfile for Color replacement arrays by Renx. by Brandon Allen (crio49@hotmail.com) on Monday, September 18th @ 01:40:24 PM http:// |
# COLOR CODES Colors are: &n&&n - normal &n&&d - &dblack &n&&D - &Dgray &n&&0 - &0background black &n &n&&b - &bblue &n&&B - &Bbright blue &n&&1 - &1background blue &n &n&&g - &ggreen &n&&G - &Gbright green &n&&2 - &2background green &n &n&&c - &ccyan &n&&C - &Cbright cyan &n&&3 - &3background cyan &n &n&&r - &rred &n&&R - &Rbright red &n&&4 - &4background red &n &n&&m - &mmagneta &n&&M - &Mbright magneta &n&&5 - &5background magneta&n &n&&y - &yyellow &n&&Y - &Ybright yellow &n&&6 - &6background yellow &n &n&&w - &wwhite &n&&W - &Wbright white &n&&7 - &7background white &n Extra codes: &n&&l - &lblink &n&&o - &obold &n &n&&u - &uunderline &n&&e - &ereverse video &n&&&n&& - single &n&& &n |
[ Reply to this comment ] |