Welcome to the Builder Academy

Question Color in the Create Character Menu

More
27 Jan 2022 03:03 #9996 by jandulio
I see when I first connect to the server the color red is shown at the top of the screen when it's figuring out my capabilities:

     <red here>          <red here>      <red here> ....
[Client] CMUD | [Colors] Ansi | [MXP] Yes | [MSDP] No | [ATCP] No

The problem is, I'm having trouble getting color to show up in the main menus of the mud where you choose your character class.  I've tried "@g" color combinations and "\tG" with no luck.

I even tried copy/pasting the values from the capabilities and that doesn't work either.  Hoping someone has some ideas, thanks.

Please Log in or Create an account to join the conversation.

More
28 Jan 2022 18:56 #9997 by thomas
Quite strange.

The correct code in should be \t<code> (ie \tg).

Please Log in or Create an account to join the conversation.

More
28 Jan 2022 19:27 #9998 by jandulio
I tried \tg, \tn, all of them.

I actually don't see the \tg when it prints, but there is no color either. It's like it knows it's a color code, but just doesn't do it. Colors look while in-game no problem, I use them all over the place. It's just this one area that I can't get to work. The Male/Female, Class, etc. screens are where I have the issue.

Agreed, it's very odd. I'm going to try to debug it sometime today or tomorrow, but the parsing stuff is difficult to look at so crossing my fingers it's not too crazy.

Please Log in or Create an account to join the conversation.

More
30 Jan 2022 22:56 #10001 by thomas
Ok, got around to testing this, finally.

The "\t" character is an actual tab character. This is quite easy to insert directly when editing the file (though it won't look nice in your editor with a bunch of whitespace thrown in). In this example, the word "name" is in blue:
Code:
$ cat ../lib/text/greetings ... By what Bname n do you wish to be known? output: By what name do you wish to be known?

In "internal" strings in the code, like the password prompt, a tab char is difficult to work with, so you can use \t there:
Code:
REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_MAILING); REMOVE_BIT_AR(PLR_FLAGS(d->character), PLR_CRYO); d->character->player.time.logon = time(0); - write_to_output(d, "Password: "); + write_to_output(d, "Pa\tOss\tGword:\tn "); echo_off(d); d->idle_tics = 0; STATE(d) = CON_PASSWORD;
Outputs Password with ss in "orange" and "word" in green.

Please Log in or Create an account to join the conversation.

More
31 Jan 2022 19:49 #10003 by jandulio
Thanks for the reply @Thomas

Color works on the password line for me when logging in an already-created character, but not when I am creating a new character...

Can you try this:

default:
write_to_output(d, "That is not a sex..\r\n"
"What IS your sex? ");
return;
}

- write_to_output(d, "%s\r\n\tOClass: ", class_menu);
+ write_to_output(d, "%s\r\n Class: ", class_menu);

This is the character selection screen (the one I am having issues with).

This doesn't work for me, but it's possible that I have something else messing this up with my highly modified code.

Please Log in or Create an account to join the conversation.

More
01 Feb 2022 23:46 #10012 by thomas
Ah, well I debugged a bit. There is a check for "color level" in the protocol.c file (on line 2518) where it checks the preferences of the player.
New players have "no prefs" - defaulting to no color to show (their character struct is empty).

If we want them to have color by default, which we probably would if they support it, we must set the relevant preferences in interpreter.c:
Code:
diff --git a/src/interpreter.c b/src/interpreter.c index 0dadad0..92eabc4 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -1409,7 +1409,13 @@ void nanny(struct descriptor_data *d, char *arg) CREATE(d->character->player.name, char, strlen(tmp_name) + 1); strcpy(d->character->player.name, CAP(tmp_name)); /* strcpy: OK (size checked above) */ GET_PFILEPOS(d->character) = player_i; - write_to_output(d, "Did I get that right, %s (\t(Y\t)/\t(N\t))? ", tmp_name); + + if (d->pProtocol && (d->pProtocol->pVariables[eMSDP_ANSI_COLORS] || d->pProtocol->pVariables[eMSDP_XTERM_256_COLORS])) { + SET_BIT_AR(PRF_FLAGS(d->character), PRF_COLOR_1); + SET_BIT_AR(PRF_FLAGS(d->character), PRF_COLOR_2); + } + + write_to_output(d, "Did I get that right, %s (\t(Y\t)/\t(N\t))? ", tmp_name); STATE(d) = CON_NAME_CNFRM; } else { /* undo it just in case they are set */ @@ -1433,6 +1439,11 @@ void nanny(struct descriptor_data *d, char *arg) CREATE(d->character->player.name, char, strlen(tmp_name) + 1); strcpy(d->character->player.name, CAP(tmp_name)); /* strcpy: OK (size checked above) */ + if (d->pProtocol && (d->pProtocol->pVariables[eMSDP_ANSI_COLORS] || d->pProtocol->pVariables[eMSDP_XTERM_256_COLORS])) { + SET_BIT_AR(PRF_FLAGS(d->character), PRF_COLOR_1); + SET_BIT_AR(PRF_FLAGS(d->character), PRF_COLOR_2); + } + write_to_output(d, "Did I get that right, %s (\t(Y\t)/\t(N\t))? ", tmp_name); STATE(d) = CON_NAME_CNFRM; }
The following user(s) said Thank You: jandulio

Please Log in or Create an account to join the conversation.

Time to create page: 0.197 seconds