This is a relatively simple include file that aims to improve basic message sending with NWN2. It includes 5 basic functions for sending text to players with color text support.
Why use this?
SendMessageToPC() and FloatingTextString() do not support coloring text inherently. Second, the format between the two is not consistent. Third, they are long functions to type. Finally, party messaging / DM messaging / Variable based messaging are not strongly supported without writing the code yourself. This include file addresses each of these issues. I wrote it for myself for DMFI development and have uploaded it here for public use.
It is a sub-component of the future DMFI Tools for NWN2. It is also a sub-component of the Custom Token Dialog System.
Documentation is included. If there are errors, please post and they will be corrected.
Included functions:
SentText(): Player / faction color messaging.
SendTalkText(): Forced speak color messaging.
SendDMText(): DM oriented color messaging.
SendPartyText(): Party based color messaging.
SendPCText(): PC Integer state based color messaging.
ColorText(): Add color text support.
Revision Log:
1a1: Only function changed was ColorText(). Fixed a few colors that were not working and spent an hour tweaking the various colors so that they were more varied.
The point is, as stated, a simple wrapper that makes doing a few things simplier - at least IMO. It doesn't attempt or pretend to do anything revolutionary.
It was released day 1 and offers a nice easy method to send text messages in color without knowledge of hex values and other things that non-programmers may not be familiar with as well as several other features listed above.
But if it doesn't suit your needs, that is fine - hopefully it helps some people. Thanks for stopping by.
Okay I did the same mistake as 0100010. Screw it. _________________________ Sundren, A Neverwinter Nights 2 Persistent World in the Forgotten Realms setting.
Sorry, it seems the vault comment system parsed out my code... After doing the " but before the 'text here' I put "" and at the end I did "" (without the quotes). There are several other html-style functions like this in NWN2, like changing the font. Though I don't think the font changing works. _________________________ Sundren, A Neverwinter Nights 2 Persistent World in the Forgotten Realms setting.
Not to be rude, but what is the point in this script?
You could just do SendMessageToPC(oPC, "Text here");
Of course you can substitute red for a HEX value as well. This works with floatingtextstring on creature and I think pretty much everywhere else in the engine as well. _________________________ Sundren, A Neverwinter Nights 2 Persistent World in the Forgotten Realms setting.
For many functions, like SendText, you can specify whether the text is floating or not. If the text is floating, it uses FloatingTextStringOnCreature to send the message and if not, it uses SendMessageToPC. If I understand correctly:
SendText(oPC, "Text", FALSE, COLOR_RED);
Sends a red text message to the chat window only via SendMessageToPC().
I agree both work. For me, I'm staying put I think.
Here is why I went the way I did. I wanted early scripters to use colors and the COLOR constants are in the scripting language and I thought it would be confusing to actually NOT use them. Secondly, consistency in using different colors is a priority in my opinion so I thought people were better off to have 16 (or so) colors that were reasonably different yet consistent and readily at hand rather than remembering values or creating near duplicate constants. I thought that using 10 colors well was a higher priority than have infinite colors availables.
So yes that works, but this was a design decision that approaches coloring text from a little more simplistic, consistent, yet straightforward approach.
I appreciate the comments. If I'm missing something where you get the flexibility / ease of use of both - slap me. :)
//Adds a color token to sText from the given RGB values
string ColorText(string sText, int nRed=255, int nGreen=255, int nBlue=255)
{
int nRGB = (nRed * 65536) + (nGreen * 256) + nBlue;
string sColorHex = GetSubString(IntToHexString(nRGB),2, 8);
return "" + sText + "";
}
This gives you the full range of RGB colors instead of being limited to the pre-selected ones.
Posted by camelbox at 2006-11-18 10:00:42 Voted 10.00 on 11/18/06
I hate having the need for the revision, but in fact, it is needed. A 2 of 17 colors would not display properly. I also spent time tweaking several colors to make them more varied within a conversation.
You must be Logged In to post comments in this section.
10 - A Masterpiece, Genuinely Groundbreaking 9 - Outstanding, a Must Have 8 - Excellent, Recommended to Anyone 7 - Very Good, Deserves a Look 6 - Good, Qualified Recommendation 5 - Fair, Solid yet Unremarkable 4 - Some Merit, Requires Improvements 3 - Poor Execution, Potential Unrealized 2 - Very Little Appeal 1 - Not Recommended to Anyone