Aller au contenu

Photo

Using color tokens in conversation.


  • Veuillez vous connecter pour répondre
18 réponses à ce sujet

#1
MadHaTr

MadHaTr
  • Members
  • 7 messages
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?

#2
Lovelamb

Lovelamb
  • Members
  • 38 messages
 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 .


#3
Melkior_King

Melkior_King
  • Members
  • 135 messages
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.

#4
Highv Priest

Highv Priest
  • Members
  • 93 messages
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.

#5
Squatting Monk

Squatting Monk
  • Members
  • 444 messages
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.

#6
Highv Priest

Highv Priest
  • Members
  • 93 messages

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.

#7
Squatting Monk

Squatting Monk
  • Members
  • 444 messages
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."

#8
Highv Priest

Highv Priest
  • Members
  • 93 messages
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.

#9
Squatting Monk

Squatting Monk
  • Members
  • 444 messages
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.

#10
henesua

henesua
  • Members
  • 3 863 messages
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)

#11
Sir Adril

Sir Adril
  • Members
  • 63 messages
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?

#12
Squatting Monk

Squatting Monk
  • Members
  • 444 messages
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 .


#13
henesua

henesua
  • Members
  • 3 863 messages
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.

#14
Sir Adril

Sir Adril
  • Members
  • 63 messages
Thank you both for those, they're very helpful :D

#15
Highv Priest

Highv Priest
  • Members
  • 93 messages
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>";
}

#16
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

Highv Priest wrote...

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).

...


So why not just use the one that already comes with the game?  It Allows for 343 colors.  

From x3_inc_string : 

// FILE: x3_inc_string      FUNCTION: StringToRGBString()
//
// This function will make sString be the specified color
// as specified in sRGB.  RGB is the Red, Green, and Blue
// components of the color.  Each color can have a value from
// 0 to 7.
// Ex: red   == "700"
//     green == "070"
//     blue  == "007"
//     white == "777"
//     black == "000"
// The STRING_COLOR_* constants may be used for sRGB.
string StringToRGBString(string sString, string sRGB); 

Modifié par Lightfoot8, 03 février 2013 - 07:54 .


#17
Squatting Monk

Squatting Monk
  • Members
  • 444 messages
Yeah, we use both methods. Nine times out of ten, though, the ones in the constants work well enough, and you can always define more if you find yourself using the same color frequently. But the flexibility of the RGB method is crazy useful.

Here's some more functions from our color library (including some helper functions for coloring spoken strings and floating text). These work with either the constants method or the RGB method.


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

string GetStringColored(string sString, string sColor)
{
    return sColor + sString + COLOR_END;
}

string GetColorCode(int nRed=255, int nGreen=255, int nBlue=255)
{
    return "<c" + GetSubString(COLOR_TOKEN, nRed, 1) + GetSubString(COLOR_TOKEN, nGreen, 1) + GetSubString(COLOR_TOKEN, nBlue, 1) + ">";
}

string GetStringColoredRGB(string sString, int nRed=255, int nGreen=255, int nBlue=255)
{
    return "<c" + GetSubString(COLOR_TOKEN, nRed, 1) + GetSubString(COLOR_TOKEN, nGreen, 1) + GetSubString(COLOR_TOKEN, nBlue, 1) + ">" + sString + "</c>";
}

void SpeakColorString(string sString, int nTalkVolume=TALKVOLUME_TALK, string sColor = COLOR_DEFAULT)
{
    if (sColor != COLOR_DEFAULT) sString = sColor + sString + COLOR_END;
    SpeakString(sString, nTalkVolume);
}

void FloatingColorText(string sStringToDisplay, object oCreatureToFloatAbove, int bBroadcastToFaction=TRUE, string sColor = COLOR_DEFAULT)
{
    if (sColor != COLOR_DEFAULT) sStringToDisplay = sColor+sStringToDisplay+COLOR_END;
    FloatingTextStringOnCreature(sStringToDisplay, oCreatureToFloatAbove, bBroadcastToFaction);
}

Modifié par Squatting Monk, 03 février 2013 - 08:06 .


#18
Sir Adril

Sir Adril
  • Members
  • 63 messages
Honestly, speaking as an artist, I actually agree that just because a game can render all those colors, doesn't mean people can tell the difference. Colors that are very close in hue and/or saturation can be almost impossible for the human eye to distinguish. Now I'm sure you all know this, but for future benefit of other readers later, all you really need to do is to create a spectrum of colors, equally spaced, and subtly different from each other, and it will appear you've used the entire range of colors within the game.

#19
Highv Priest

Highv Priest
  • Members
  • 93 messages
I wanted to use the full spectrum of colors to allow players to color their chat text in any unique way as they saw fit(whether they made it visible or not). Also it wasn't particularly harder to use the full range then the normal range, quite the opposite in fact. It was easier to encompass all colors then to focus on a set of colors. Creating that function took me all of 3 minutes to accomplish whereas creating specific libraries of colors would of taken about 30, but to each his own.

EDIT = In response to Lightfoot, I was unaware such a function existed. 99% of the things I do are completely made from scratch because the time it takes to fix problems caused by using other people's work is more then it takes for me to make my own.

Modifié par Highv Priest, 04 février 2013 - 03:53 .