|
Post by Tellenger on Jan 24, 2008 4:59:02 GMT
I'm attempting to script a command that will enable DMs to speak colored text by first typing the "[" key followed by the text they wish the players to see. I've modified the fky_chat and fky_chat_inc as follows to enable the color text:
fky_chat
// Added for DM colored text. // Added By: Pax 21 January 08 else if ((sType == "[") && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) HandleDMSpeech(oPC, sText, nChannel, sLogMessageTarget);//DM color text.
fky_chat_inc
void HandleDMSpeech(object oDMPC, string sDMText, int nDMChannel, string sDMLogMessageTarget) { switch(nDMChannel)//all speech besides emotes, player commands, and metachannels - sort by channel { ////////////DM speaker channels from 17-30 /*talk*/ //case 17: /*shout*/ //case 18: /*whisper*/ //case 19: /*tell*/ case 20: //HandleDMTraffic(oHOPC, oHOTarget, sHOText, sHOLogMessageTarget, nHOChannel);//handles dm traffic and tell forwarding//now handled earlier DMTellForwarding(oDMPC, sDMLogMessageTarget, sDMText, nDMChannel); //check for tell options break; /*party*/ //case 22: /*dm*/ case 30: if (DM_PLAYERS_HEAR_DM) DMChannelForwardToDMs(oDMPC, sDMText); //check for dm players hearing dm if (ADMIN_PLAYERS_HEAR_DM) DMChannelForwardToAdmins(oDMPC, sDMText);//check for admin players hearing dm break; }
sDMText = COLOR_SKY_BLUE + sDMText + COLOR_END; SpeakString(sDMText, TALKVOLUME_TALK); SetLocalString(oDMPC, "NWNX!CHAT!SUPRESS", "1"); }
At present, the colored text can be seen by the speaking DM and other DMs. However, players are reporting that they are seeing no text at all. COLOR_SKY_BLUE is defined in fky_chat_constants.
Is this function setup correctly to accomplish the above desired result?
Thanks.
Tellenger
|
|
|
Post by FunkySwerve on Jan 24, 2008 5:35:11 GMT
Not even remotely. If you want the dm speech function to handle it you need to let it pass down, not make a check at the top. I'd spend some more time looking at fky_chat to understand the flow. What you want to do is reletively simple, and a custom wrapper checked at the top is probably the simplest solution. You need to realize when you do that, though, it prevents the rest of the processing, in fashion similar to emotes and commands. Forget using the SIMTools function.
Funky
|
|
|
Post by Tellenger on Jan 24, 2008 7:30:01 GMT
Ha! I was that close, eh? This is the first time working with NWNX, and I'm having a little difficulty understanding exactly how typed text is transfered and processed. Please forgive me if I'm asking remedial questions. Are you refering to the fky_chat or the HandleDMSpeech() function? I'm assuming you mean a check for the "[" near the top of fky_chat to convert sText to color and allow it to continue down through fky_chat. Something more like the following code? #include "fky_chat_inc"
void main() { //////////////////////////////////Declarations////////////////////////////////// object oPC = OBJECT_SELF, oTarget;// Speaker = oPC string sText, sLogMessage, sLogMessageTarget, sType, sSort; int nChannel, nTarget; /////////////////////////Gather Message and Target Data///////////////////////// SetLocalString(oPC, "NWNX!CHAT!TEXT", Speech_GetSpacer()); // Query for chattext sText = GetLocalString(oPC, "NWNX!CHAT!TEXT"); // Get chattext nChannel = StringToInt(GetStringLeft(sText, 2)); // Get channel nTarget = StringToInt(GetSubString(sText, 2, 10)); // Target ID - Return value of -1 is no target. IE, not a tell/privatemessage sText = GetStringRight(sText, GetStringLength(sText) - 12);// Remove Target & Channel Info if( nTarget != -1 )// Acquire possible target { oTarget = Speech_GetPlayer(nTarget); sLogMessageTarget = "->" + GetName(oTarget) + "(" + GetPCPlayerName(oTarget) + ")"; ///////////////////////////////////DM Stealth/////////////////////////////////// if (GetLocalInt(oTarget, "FKY_CHAT_DMSTEALTH") && (oTarget != oPC)) {DoStealth(oPC, oTarget, sText, nChannel, sLogMessageTarget); return;} } sType = GetSubString(sText, 0, 1);//this is the primary sorting string, the leftmost letter of the text // Added for DM colored text. // Added By: Pax 21 January 08 if ((sType == "[") && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) sText = COLOR_SKY_BLUE + sText + COLOR_END;//DM color text. ///////////////////////////////Command Completion/////////////////////////////// int nCompletion = GetLocalInt(oPC, "FKY_CHAT_COMMAND_COMPLETE"); if (nCompletion) DoCommandCompletion(oPC, sText, nCompletion); ////////////////////////////////Speech Processing/////////////////////////////// else if ((sType == EMOTE_SYMBOL) && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) HandleEmotes(oPC, sText, nChannel);//emotes - taken from Emote-Wand V1000 UpDate Scripted By: Butch (with edits) else if ((sType == COMMAND_SYMBOL) && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) HandleCommands(oPC, oTarget, sText, nChannel);//commands else if (sType == "|")// metachannels and languages { SetLocalString(oPC, "NWNX!CHAT!SUPRESS", "1"); sText = GetStringRight(sText, GetStringLength(sText) - 1); sSort = GetStringLeft(sText, 2); if (ENABLE_LANGUAGES && sSort == "l ") HandleOneLiners(sText, oPC, nChannel);//must be a space after the /l else if (ENABLE_METACHANNELS && sSort == "m ") HandleMetaMessage(sText, oPC);//must be a space after the /m else if ((VerifyDMKey(oPC) || VerifyAdminKey(oPC)) && sSort == "v ") HandleVentrilo(sText, oPC);//must be a space after the /m else FloatingTextStringOnCreature(COLOR_RED+BADCHANNEL+COLOR_END, oPC, FALSE); } else if ((GetStringLowerCase(GetStringLeft(sText, 3)) == "dm_") && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) { //HandleDMTraffic(oPC, oTarget, sText);//this has been moved to a new script to allow compiler to digest it SetLocalObject(oPC, "FKY_CHAT_DMSHUNT_TARGET", oTarget);//these locals pass the needed values to the new script SetLocalString(oPC, "FKY_CHAT_DMSHUNT_TEXT", sText); ExecuteScript("fky_chat_dm_comm", oPC); } else HandleOtherSpeech(oPC, oTarget, sText, nChannel, sLogMessageTarget); ////////////////////////////////////Logging///////////////////////////////////// if (TEXT_LOGGING_ENABLED) DoLogging(oPC, sLogMessageTarget, nChannel, sText); ////////////////////////////////////Cleanup///////////////////////////////////// DoCleanup(oPC); } Tellenger
|
|
|
Post by FunkySwerve on Jan 24, 2008 16:16:46 GMT
Yup, that'll work, though you probably want to parse out the '[', meaning you'll have to bracket the if statement:
if ((sType == "[") && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) { sText = GetStringRight(sText, GetStringLength(sText) - 1); sText = COLOR_SKY_BLUE + sText + COLOR_END;//DM color text. }
Funky
|
|
|
Post by Tellenger on Jan 27, 2008 15:47:17 GMT
FunkySwerve,
After making the above modifications, text typed by a DM preceeded by a "[" is not converted to color, at least from the DM's perspective. I have not tested this with a player present yet to determine if they see the color text. Is this supposed to occur this way?
Here is the completed fky_chat script:
Thanks.
Tellenger
|
|
|
Post by FunkySwerve on Jan 27, 2008 16:09:46 GMT
What DOES happen? Did you recompile? Funky
|
|
|
Post by Tellenger on Jan 27, 2008 16:14:22 GMT
The text comes through in the chat window as white, the same as it would if you had normally typed the text without this script.
Yeah, I recompiled several times.
Tellenger
|
|
|
Post by FunkySwerve on Jan 27, 2008 16:16:53 GMT
With the color code? Without? Show me a sample sentence, please, and exactly what it looks like after passing through the script. The more info you give me, the less wasted back and forth. Funky
|
|
|
Post by Tellenger on Jan 27, 2008 16:28:52 GMT
Here is a screenshot of the typed text with the color code in place. The text in the chat window should be a grey-blue color, not white.
|
|
|
Post by FunkySwerve on Jan 27, 2008 16:48:36 GMT
It occurs to me that you never have them speak the changed text. You need to suppress it using: SetLocalString(oPC, "NWNX!CHAT!SUPRESS", "1"); And then assigncommand them to speak the changed text string. That suppresses the old spoken line and initiates a new chat event using the colored text. Sorry, still waking up here. Also, since I notice that isn't a color code used in SIMTools, please post the const definition so I can have a look at it. Funky
|
|
|
Post by Tellenger on Jan 27, 2008 17:01:06 GMT
Funky, Heh, nothing like the feeling of an early Sunday morning. Here is the color definition. I tested it through a short script to be sure the definition was working correctly. It does work. const string COLOR_SKY_BLUE = "<c°ÄÞ>"; //dm text From what I can see, DM text gets routed through HandleOtherSpeech() in fky_chat_inc in which it just passes through. Would the SetLocalString(oPC, "NWNX!CHAT!SUPRESS", "1"); and assigncommand need to entered in this script in the appropriate channel? Here for instance: ////////////DM speaker channels from 17-30 /*talk*/ //case 17: SetLocalString(oPC, "NWNX!CHAT!SUPRESS", "1"); SpeakString(sHOText, nVolume);
|
|
|
Post by FunkySwerve on Jan 27, 2008 17:05:50 GMT
Replace your if line with this bracketed if:
if ((sType == "[") && (VerifyDMKey(oPC) || VerifyAdminKey(oPC))) { sText = GetStringRight(sText, GetStringLength(sText) - 1); sText = COLOR_SKY_BLUE + sText + COLOR_END;//DM color text. AssignCommand(oPC, SpeakString(sText)); SetLocalString(oPC, "NWNX!CHAT!SUPRESS", "1");//doesn't have to be placed last }
Note that doing it this way circumvents the rest of the speech processing, including channel bans, but since you have to be a DM or Admin it isn't a problem.
Funky
|
|
|
Post by Tellenger on Jan 27, 2008 17:20:31 GMT
Thanks, Funky.
One last question and I'll get out of your hair.
Using the portion of script you added above, is it necessary to call AssignCommnd?
Tellenger
|
|
|
Post by FunkySwerve on Jan 27, 2008 17:51:27 GMT
No, that was more precautionary than anything, in case the code gets moved. OBJECT_SELF is the PC.
Funky
|
|
|
Post by Tellenger on Jan 27, 2008 20:44:39 GMT
Well, the text is now colored but players are still unable to see the text which I assume is because the DM is invisible. Regular text is visible, just not the colored text. I'll have to play around with it a bit more.
|
|