Using color tokens in conversation.
#1
Posté 22 novembre 2012 - 09:58
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
Posté 08 décembre 2012 - 02:41
(Late reply, you probably figured it out.)
Modifié par Lovelamb, 08 décembre 2012 - 02:42 .
#3
Posté 06 janvier 2013 - 08:37
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
Posté 01 février 2013 - 04:34
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
Posté 01 février 2013 - 04:48
#6
Posté 01 février 2013 - 05:10
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
Posté 01 février 2013 - 05:26
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
Posté 01 février 2013 - 06:53
#9
Posté 01 février 2013 - 08:21
#10
Posté 01 février 2013 - 08:35
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
Posté 01 février 2013 - 11:31
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
Posté 02 février 2013 - 12:02
// 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
Posté 02 février 2013 - 12:45
In the spirit of sharing, I've also compiled a color include that I use in most projects.
#14
Posté 02 février 2013 - 12:56
#15
Posté 03 février 2013 - 07:16
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
Posté 03 février 2013 - 07:54
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
Posté 03 février 2013 - 08:04
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
Posté 03 février 2013 - 11:12
#19
Posté 04 février 2013 - 03:50
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 .





Retour en haut







