ok here is my problem first. I've made my own custom score sheet for my mud. but down in the language portion how it had to be set up is giving me a problem with the color. here is how it looks:
#1
Australia Forum Administrator
#2
#3
USA
#4
Australia Forum Administrator
#5
#6
#7
#8
USA
#9
#10
USA
#11
#12
+------------------------------------+ | __)| | |(__ | |Your hands are not sterile. |
| LANGUAGES | |___)| | |(___| |You feel great. |
+------------------------------------+ | | | |You are in danger of dehydrating.|
|common wookiee twilek rodian | | | | |You are starving to death. |
|hutt mon calamari noghri | | | | | |<---- this line here. Hutt is in red (cause that is what you are speaking)
|ewok gungan barabel bith | | | | +---------------------------------+
|gamorrean trianii jawa adarian | | | | | |
|verpine defel trandoshan | | | | +---------------------------------+
|chadra-fan quarren duinuogwuin | | | | | ORGANIZATION DATA |
|toydarian zabrak falleen coynite | | | | +---------------------------------+
BUT should look like this:
+------------------------------------+ | __)| | |(__ | |Your hands are not sterile. |
| LANGUAGES | |___)| | |(___| |You feel great. |
+------------------------------------+ | | | |You are in danger of dehydrating.|
|common wookiee twilek rodian | | | | |You are starving to death. |
|hutt mon calamari noghri | | | | | |
|ewok gungan barabel bith | | | | +---------------------------------+
|gamorrean trianii jawa adarian | | | | | |
|verpine defel trandoshan | | | | +---------------------------------+
|chadra-fan quarren duinuogwuin | | | | | ORGANIZATION DATA |
|toydarian zabrak falleen coynite | | | | +---------------------------------+
ok notice the line is 4 spaces short than the rest at the language portion. now if i would change from the language hutt to the language common the hutt line will look fine... BUT the common line will be short.
Her is the code that controls what one is red (if any) I'll just past the two lines that deal with the common line and the hutt line
Her is the code that controls what one is red (if any) I'll just past the two lines that deal with the common line and the hutt line
strcpy(lbuf, "&B|");
for (iLang = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++)
{
sn = skill_lookup(lang_names[iLang]);
if (sn < 0)
continue;
else if ((ch->pcdata->learned[sn] > 0 && !IS_IMMORTAL(ch)) || IS_IMMORTAL(ch))
{
if ((strlen(lbuf) + strlen(lang_names[iLang])) >= 36)
{
lcnt = iLang;
break;
}
if (ch->speaking & lang_array[iLang])
{
strcat(lbuf, "&R");
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, "&B ");
}
else
{
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, " ");
}
continue;
}
}
for (;;)
{
if (strlen(lbuf) != 39)
strcat(lbuf, " ");
else
break;
}
if (!IS_NPC(ch) && ch->pcdata->condition[COND_FULL] == 0 && !IS_SET(ch->pcdata->cyber, CYBER_REACTOR))
strcat(lbuf, "|&G | | | &B|&WYou are starving to death. &B|\n\r");
else
strcat(lbuf, "|&G | | | &B| |\n\r");
send_to_char(lbuf, ch);
strcpy(lbuf, "&B|");
for (iLang = lcnt, lcnt = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++)
{
sn = skill_lookup(lang_names[iLang]);
if (sn < 0)
continue;
else if ((ch->pcdata->learned[sn] > 0 && !IS_IMMORTAL(ch)) || IS_IMMORTAL(ch))
{
if ((strlen(lbuf) + strlen(lang_names[iLang])) >= 36)
{
lcnt = iLang;
break;
}
if (ch->speaking & lang_array[iLang])
{
strcat(lbuf, "&R");
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, "&B ");
}
else
{
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, " ");
}
continue;
}
}
for (;;)
{
if (strlen(lbuf) != 39)
strcat(lbuf, " ");
else
break;
}
if (!IS_NPC(ch) && ch->pcdata->condition[COND_DRUNK] > 10)
strcat(lbuf, "|&G | | | &B|&WYou are drunk. &B|\n\r");
else
strcat(lbuf, "|&G | | | &B| |\n\r");
send_to_char(lbuf, ch);
Your "spoken" line is 4 characters short, and the codes to put it into a different colour are 4 characters: &R and &B.
So, you need to adjust the compensation for the width to allow for the fact that that line is 4 characters longer (well, 4 characters less in printable characters).
So, you need to adjust the compensation for the width to allow for the fact that that line is 4 characters longer (well, 4 characters less in printable characters).
Yeah i know this... i just can't figure out how with out the mud crashing LOL
What are you doing to make it crash? Use gdb to report the backtrace here.
It would help to post the code, as modified, that you say crashes. Also you can help yourself by checking out the loop inside gdb, as Zeno said, to do this see this article:
http://www.gammon.com.au/forum/?id=3653
http://www.gammon.com.au/forum/?id=3653
ok it no longer crashes i have made some progress and here is what i have
this is the original code and made the line look like this
strcpy(lbuf, "&B|");
for (iLang = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++)
{
sn = skill_lookup(lang_names[iLang]);
if (sn < 0)
continue;
else if ((ch->pcdata->learned[sn] > 0 && !IS_IMMORTAL(ch)) || IS_IMMORTAL(ch))
{
if ((strlen(lbuf) + strlen(lang_names[iLang])) >= 36)
{
lcnt = iLang;
break;
}
if (ch->speaking & lang_array[iLang])
{
strcat(lbuf, "&R");
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, "&B ");
}
else
{
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, " ");
}
continue;
}
}
for (;;)
{
if (strlen(lbuf) != 39)
strcat(lbuf, " ");
else
break;
}
if (!IS_NPC(ch) && ch->pcdata->condition[COND_FULL] == 0 && !IS_SET(ch->pcdata->cyber, CYBER_REACTOR))
strcat(lbuf, "|&G | | | &B|&WYou are starving to death. &B|\n\r");
else
strcat(lbuf, "|&G | | | &B| |\n\r");
send_to_char(lbuf, ch);
this is the original code and made the line look like this
+------------------------------------+ | __)| | |(__ | |Your hands are not sterile. |
| LANGUAGES | |___)| | |(___| |You feel great. |
+------------------------------------+ | | | |You are in danger of dehydrating.|
|common wookiee twilek rodian | | | | |You are starving to death. |<---- this line here. common is in red (cause that is what you are speaking)
|hutt mon calamari noghri | | | | | |
|ewok gungan barabel bith | | | | +---------------------------------+
|gamorrean trianii jawa adarian | | | | | |
|verpine defel trandoshan | | | | +---------------------------------+
|chadra-fan quarren duinuogwuin | | | | | ORGANIZATION DATA |
|toydarian zabrak falleen coynite | | | | +---------------------------------+
now i altered the code to look like this:
the line if( strlen(lbuf) !=39); was changed to 43 instead... that gave me the 4 spaces back. but now if i'm not speaking a lang on that line it moves 4 spaces forward. is there a way to get it to stop moving back and forth or is it a loss cause?
strcpy(lbuf, "&B|");
for (iLang = 0; lang_array[iLang] != LANG_UNKNOWN; iLang++)
{
sn = skill_lookup(lang_names[iLang]);
if (sn < 0)
continue;
else if ((ch->pcdata->learned[sn] > 0 && !IS_IMMORTAL(ch)) || IS_IMMORTAL(ch))
{
if ((strlen(lbuf) + strlen(lang_names[iLang])) >= 36)
{
lcnt = iLang;
break;
}
if (ch->speaking & lang_array[iLang])
{
strcat(lbuf, "&R");
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, "&B ");
}
else
{
strcat(lbuf, lang_names[iLang]);
strcat(lbuf, " ");
}
continue;
}
}
for (;;)
{
if (strlen(lbuf) != 43)
strcat(lbuf, " ");
else
break;
}
if (!IS_NPC(ch) && ch->pcdata->condition[COND_FULL] == 0 && !IS_SET(ch->pcdata->cyber, CYBER_REACTOR))
strcat(lbuf, "|&G | | | &B|&WYou are starving to death. &B|\n\r");
else
strcat(lbuf, "|&G | | | &B| |\n\r");
send_to_char(lbuf, ch);
the line if( strlen(lbuf) !=39); was changed to 43 instead... that gave me the 4 spaces back. but now if i'm not speaking a lang on that line it moves 4 spaces forward. is there a way to get it to stop moving back and forth or is it a loss cause?
The problem is that the extra &R and &B strings are adding 4 spaces to your string.
To fix this, just set a flag if the character is speaking something, and if so, add 4 to 43.
To fix this, just set a flag if the character is speaking something, and if so, add 4 to 43.
david my problem was before that it was set to 39... when i was speaking a lang on that like (common) it was 4 spaces to short... I added 4 to 39... got 43.... so now when i am speaking common that line is ok... but lets say i change to the hutt lang on the next line down... the common line is then 4 spaces to long cause i added the 4. so if i add 4 again it is going to be 4 spaces to long when speaking common and 8 spaces to long when speaking hutt.. so i don't see how that will help
Then just count how many color codes you emitted and compensate accordingly by adding two to the length you pad to per color code.
I'm not saying to just add 4 spaces without thinking. I'm saying that you need compensate for the color codes, which contribute to the string length but are not in fact actually printed.
Stop and think about the problem on paper, that might help. Draw out the character arrays and see what happens.
I'm not saying to just add 4 spaces without thinking. I'm saying that you need compensate for the color codes, which contribute to the string length but are not in fact actually printed.
Stop and think about the problem on paper, that might help. Draw out the character arrays and see what happens.
just a question...but have you tried the set_char_color(b, AT_RED) thingy instead of using the color tags? Probably have, but i'm just trying to make myself look like I almost know what I"m talking about...which I don't, really...I can't get the set_char_color thingy to work worth a tinker's fit...but you'd probably have more luck with it than me.