Author Topic: Using color tokens in conversation.  (Read 1124 times)

Legacy_MadHaTr

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Using color tokens in conversation.
« on: November 22, 2012, 09:58:48 pm »


               I am trying to get colors into conversation as I've seen in a few examples and tutorials but it is not working.  

If I place the token in a placeables desciption they work fine.   I'm looking at Hitchhikers guide to color tokens and they just will not work in my conversations.  I keep seeing  UNRECOGNIZED TOKEN in game for both the open <c ÿ > and the close </c>

What gives?
               
               

               
            

Legacy_Lovelamb

  • Jr. Member
  • **
  • Posts: 68
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #1 on: December 08, 2012, 02:41:33 pm »


                I just made it work today (after finding the tutorial). For conversations, journal or item names (I think) you need to set two <CUSTOM###> tokens in a script, one with the value of your opening tag "<c???>" and another with "</c>".
(Late reply, you probably figured it out.)
               
               

               


                     Modifié par Lovelamb, 08 décembre 2012 - 02:42 .
                     
                  


            

Legacy_Melkior_King

  • Full Member
  • ***
  • Posts: 234
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #2 on: January 06, 2013, 08:37:26 am »


               What I did for this was make a hidden area (players can't go there) and put a container there.  I created an item (with different tags) for each color I'm going to use for text and put them into the container.  The name of each item is just a color tag.

In an include file for scripts, I access each item and assign its name to a variable.  If I use the include file at the start of a script, I can use the variables to change colors.

EG:
SendMessageToPC(oPC,TOKEN_RED+"You died"+TOKEN_END+" you poor schmuk.");
That makes "You died" appear in red and "you poor schmuk." appear in the default color.

I feel that this is a better solution since the token names are easier to remember and you don't have to remember which numbers you've used for your custom tokens and therefore which are free for use.
               
               

               
            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #3 on: February 01, 2013, 04:34:25 am »


               Err neither one of these methods are particularly good... I used "Neverwinter Color Tag Creator" which generates the colors for you. Then I captured the algorithm used by the program to create an NPC in my server that does the exact same thing, but lets me see them dynamically in conversations. As for the second poster that's just wrong. A good example comes from the guild system I use:
string sData = sColor+Guild_OBR+"\\n"+sLeader+COLOR_END+"\\n"+
sAdvo+" "+sDE+" "+sBoS+"\\n"+sColor+sTerries+"\\n"+sTatus+"\\n"+sColor+"Guild Level:"+sLevel+COLOR_END+"\\n"+
sRank1+"\\n"+sRank2+"\\n"+sRank3+"\\n"+sRank4+"\\n"+sRank5+"\\n"/*+sPosition+*/+"Guild Message:"+sColor+sMessage+COLOR_END;
SetCustomToken(161, sData);

ALL of that is stuffed into a single custom token. A good example for coloring would be: <c þ >+sMessage+</c>
You could store that entire string as one custom token and it works just fine.
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #4 on: February 01, 2013, 04:48:28 am »


               Lovelamb's method works without needing to use any conversation scripts, though. Just set the color tokens OnModuleLoad and use them throughout the module, no extra scripting required. This is what FP did in Almraiven, and it worked really well.
               
               

               
            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #5 on: February 01, 2013, 05:10:29 am »


               

Lovelamb wrote...

 I just made it work today (after finding the tutorial). For conversations, journal or item names (I think) you need to set two <CUSTOM###> tokens in a script, one with the value of your opening tag "<c???>" and another with "</c>".
(Late reply, you probably figured it out.)


I don't see an explanation of any of these being set globally(although that is what SetCustomToken does, it is not outright explained as thus). Also I didn't use the conversation for the NPC to create the colors, I used it to see them. With it storing the color tag of that color permanently as a string which I then retrieved as I see fit. If you can make the computer do all the boring work for you, it's worth it.
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #6 on: February 01, 2013, 05:26:48 am »


               The explanation is given in The Hitchhiker's Guide to Color Tokens, which is what the OP and Lovelamb were talking about.

If you're doing a lot of colors in conversations or descriptions (which is what the OP was looking for), Lovelamb's method is simple and easy to implement. There are times when your method is better, of course, but that doesn't mean Lovelamb's method is "just wrong."
               
               

               
            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #7 on: February 01, 2013, 06:53:22 pm »


               Oh no I wasn't referring to that. I was referring to the message, "For conversations, journal or item names (I think) you need to set two <CUSTOM###> tokens in a script, one with the value of your opening tag "<c???>" and another with "</c>"." This is not at all the case. You can store very large amounts of information within a single custom token.
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #8 on: February 01, 2013, 08:21:34 pm »


               Ah. Yeah, you don't need to do it like that, but it's a useful trick and it's what the guide the OP was following said to do.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #9 on: February 01, 2013, 08:35:01 pm »


               Thats a really interesting trick. Something I would like to try.

For the most part however I use dynamic conversations, I'll see how this works there. (Color has a history of bugginess with z-dialog, but I'll see what I can do with zz-dialog and kato yangs work)
               
               

               
            

Legacy_Sir Adril

  • Jr. Member
  • **
  • Posts: 96
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #10 on: February 01, 2013, 11:31:46 pm »


               Melkior King's method sounds interesting, it would make it easier to work with in my module.

Is there a way I can do that without creating all those items, some way to define easier to remember names in an include script, perhaps?
               
               

               
            

Legacy_Squatting Monk

  • Hero Member
  • *****
  • Posts: 776
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #11 on: February 02, 2013, 12:02:03 am »


               Just dump this in an include file:

// In format <cRGB> where RGB are ALT codes (0-0255) for colors
const string COLOR_BLACK        = "<c   >";
const string COLOR_BLUE         = "<c㠓>";
const string COLOR_BLUE_DARK    = "<c74°>";
const string COLOR_BLUE_LIGHT   = "<c³óþ>";    // Cyan
const string COLOR_BROWN        = "<cÅ“R0>";
const string COLOR_BROWN_LIGHT  = "<cЁK>";
const string COLOR_DIVINE       = "<cþìÚ>";
const string COLOR_GOLD         = "<cýÕ >";
const string COLOR_GRAY         = "<c|||>";
const string COLOR_GRAY_DARK    = "<cZZZ>";
const string COLOR_GRAY_LIGHT   = "<c´´´>";
const string COLOR_GREEN        = "<c=É=>";
const string COLOR_GREEN_DARK   = "<c d >";
const string COLOR_GREEN_LIGHT  = "<c|ý >";
const string COLOR_ORANGE       = "<cþ¤ >";
const string COLOR_ORANGE_DARK  = "<cþ| >";
const string COLOR_ORANGE_LIGHT = "<cþ¸ >";
const string COLOR_RED          = "<cþ(;>";
const string COLOR_RED_DARK     = "<cÅ“99>";
const string COLOR_RED_LIGHT    = "<cúaU>";
const string COLOR_PINK         = "<cúk°>";
const string COLOR_PURPLE       = "<c–2È>";
const string COLOR_TURQUOISE    = "<cKÓÎ>";
const string COLOR_VIOLET       = "<cé„ç>";
const string COLOR_VIOLET_LIGHT = "<có—ø>";
const string COLOR_VIOLET_DARK  = "<cÄ\\Ä>";
const string COLOR_WHITE        = "<cþþþ>";
const string COLOR_YELLOW       = "<cþþ >";
const string COLOR_YELLOW_DARK  = "<cÐÎ >";
const string COLOR_YELLOW_LIGHT = "<cþþ«>";
const string COLOR_END          = "</c>";

// By function
const string COLOR_DEFAULT   = COLOR_WHITE;
const string COLOR_ATTENTION = COLOR_ORANGE;
const string COLOR_BUG       = COLOR_RED_DARK;
const string COLOR_FAIL      = COLOR_RED;
const string COLOR_SUCCESS   = COLOR_GREEN_LIGHT;
const string COLOR_DEBUG     = COLOR_GRAY_LIGHT;
const string COLOR_INFO      = COLOR_BROWN_LIGHT;
const string COLOR_MAGIC     = COLOR_VIOLET;

               
               

               


                     Modifié par Squatting Monk, 02 février 2013 - 12:12 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #12 on: February 02, 2013, 12:45:14 am »


               Thats a great list. I think I'll borrow from it to expand my own.

In the spirit of sharing, I've also compiled a color include that I use in most projects.
               
               

               
            

Legacy_Sir Adril

  • Jr. Member
  • **
  • Posts: 96
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #13 on: February 02, 2013, 12:56:16 am »


               Thank you both for those, they're very helpful '<img'>
               
               

               
            

Legacy_Highv Priest

  • Full Member
  • ***
  • Posts: 170
  • Karma: +0/-0
Using color tokens in conversation.
« Reply #14 on: February 03, 2013, 07:16:15 pm »


               The problem is although that method DOES work, it also doesn't let you see the full scope of colors nwn can provide. There is 255^3 colors that exist in nwn.(although the human eye makes it mostly 200-300 or so).

I can't for the life of me figure out ignvault to upload it all, but this is the script I use to actually create the various colors.

const string COLORTOKEN = "                  ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¡¢£¤¥¦§¨©ª«¬¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþþ";

//Function creates a color string from ints. If sText is set to blank it will only return the color. If it's not set
//to blank then it creates a completely finished and colored text. I use the blank sText to create colors rather then
//finished strings.
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255);

string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255)
{
if(sText == "")
   return "<c" + GetSubString(COLORTOKEN, nRed, 1) + GetSubString(COLORTOKEN, nGreen, 1) + GetSubString(COLORTOKEN, nBlue, 1) + ">";
else
   return "<c" + GetSubString(COLORTOKEN, nRed, 1) + GetSubString(COLORTOKEN, nGreen, 1) + GetSubString(COLORTOKEN, nBlue, 1) + ">" + sText + "</c>";
}