Welcome to the Builder Academy

Question Bespoke Prompt

More
27 Apr 2018 09:18 #7987 by WhiskyTest
Bespoke Prompt was created by WhiskyTest
Bespoke Prompt allows players to create a personalized prompt. There are a few 'custom' prompt snippets from the Circlemud days floating around, so I went for 'bespoke'.

I borrowed heavily from original LexiMUD source.

It dispenses with, but does not remove, the DISP_HIT, DISP_MANA, etc. toggles. Removing them is unnecessary and would corrupt all players currently set preferences. Better to just reuse them for other purposes when needed.

The display command is used to set a pre-made prompt to make things quick for those who aren't that bothered about the prompt, and the implementer can add their own.

The prompt command will accept a string of characters such as %h %m %v for hitpoints, mana, move and so on.
Color codes are also accepted and changes to comm.c have been made to allow colors in prompt. (Probably the most interesting change)

The easily expandable list of values are:
%h %H %ph , current health, max health, health as a percentage
%m %M %pm , as above for mana points
%v %V %pv , as above for movement points
%g %G , gold on hand, gold in bank
%q, quest points
%x %X , current exp, exp till next level
%% , a percent sign
%_ , a newline
%O, opponents name and condition
%T, tanks name and condition
(tank = whoever your opponent is fighting if it isn't yourself)


Please share any improvements and bug fixes you come across!
Attachments:

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

More
28 Apr 2018 15:56 #7991 by Sascha
Replied by Sascha on topic Bespoke Prompt
Interesting. Thanks!

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

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

More
29 Apr 2018 00:05 #7995 by Sascha
Replied by Sascha on topic Bespoke Prompt
So first off, this is cool. Let me repeat. THIS. IS. COOL. There are a few things to it that are a little tricky and may need clarification or refinement. We've been joyfully testing this all day long over at ATB. :)

I mailed Whisky over at my game but here are some small things found so far:

1) Something about typing 'prompt' without an argument is not quite working. If you know to type 'display' the menu will come up, but otherwise you're on your own.

2) The tank display seems to display whomever is not the group leader, even if the group leader is actually tanking.

3) Could a prompt that is imm-level defined be added to show zone number and room vnum?

We love this over at ATB. It's a winner!

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

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

More
29 Apr 2018 11:58 #7997 by WhiskyTest
Replied by WhiskyTest on topic Bespoke Prompt
Glad it is of use :)

1). Yeah sorry, I need to work on including clearer instructions!

do_prompt() is used to manually set a prompt, for those that want to string together their own customizations.
Without an argument, do_prompt() should simply return the string that is currently set, or "n/a" if nothing has been set. It may be worth changing the "n/a" to something like "not set - see HELP DISPLAY" ?

Which segues to the missing help information :)
Code:
PROMPT Usage: prompt <string> Manually set a custom prompt. <string> can be made up from the following values: %h - current hitpoints %H - Max hitpoints %ph - hitpoints as a percentage %m - current mana points %M - Max mana points %pm - mana as a percentage %v - current move points %V - Max move points %pv - move as a percentage %g - gold on hand %G - gold in bank %q - quest points %x - current XP %X - XP till next level %% - show a percentage sign %_ - new line All color codes are accepted using the '@' symbol. Example: prompt %h %m %v @W>@n See also: DISPLAY TOGGLE COLOUR DISPLAY Usage: display <number> Set your prompt to a preset display. Typing display by itself will show a list of options. Example: display 2 See also: PROMPT

2.) I quickly tested this and couldn't reproduce it. Lets discuss on AtBMUD further.

3.) Absolutely! Remember when expanding this code that you lose any data that exceeds MAX_PROMPT_LENGTH, which is why I raised it by another 100 characters. Also there may be better ways to provide some information that players request, like having ROOMFLAGS turned on will show room vnums etc. Just something to consider before adding additional fields.

char *prompt_str(struct char_data *ch) in comm.c is where you make the changes.

Find an unused letter inside the switch statement
Code:
switch (*(++str)) {
Order doesn't matter, but it's nice to keep it alphabetical for next time you look at it.

Then add your new code block, eg:
Code:
case 'z': if (GET_LEVEL(ch) >= LVL_IMMORT) // add zone number for immortals snprintf(i, sizeof(i), "%d", zone_table[world[IN_ROOM(ch)].zone].number); else snprintf(i, sizeof(i), "z"); // for mortals, just add the letter Z tmp = i; break;

Adding room vnums would be very similar, change the case and the zone number for room vnum.
The following user(s) said Thank You: thomas

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

More
17 Sep 2021 04:16 #9910 by Darklands
Replied by Darklands on topic Bespoke Prompt
The prompt doesn't save after restarts. What am I missing?

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

More
17 Sep 2021 10:41 #9912 by thomas
Replied by thomas on topic Bespoke Prompt
Maybe this part?
Code:
diff -BbuprN -x '*.o' src_original/players.c src/players.c --- src_original/players.c 2018-04-24 08:22:16.840898100 +0100 +++ src/players.c 2018-04-26 19:31:34.394124400 +0100 @@ -409,6 +409,7 @@ int load_char(const char *name, struct c else if (!strcmp(tag, "Plyd")) ch->player.time.played = atoi(line); else if (!strcmp(tag, "PfIn")) POOFIN(ch) = strdup(line); else if (!strcmp(tag, "PfOt")) POOFOUT(ch) = strdup(line); + else if (!strcmp(tag, "Prmt")) GET_PROMPT(ch) = strdup(line); else if (!strcmp(tag, "Pref")) { if (sscanf(line, "%s %s %s %s", f1, f2, f3, f4) == 4) { PRF_FLAGS(ch)[0] = asciiflag_conv(f1); @@ -571,6 +572,7 @@ void save_char(struct char_data * ch) strip_cr(buf); fprintf(fl, "Desc:\n%s~\n", buf); } + if (GET_PROMPT(ch)) fprintf(fl, "Prmt: %s\n", GET_PROMPT(ch)); if (POOFIN(ch)) fprintf(fl, "PfIn: %s\n", POOFIN(ch)); if (POOFOUT(ch)) fprintf(fl, "PfOt: %s\n", POOFOUT(ch)); if (GET_SEX(ch) != PFDEF_SEX) fprintf(fl, "Sex : %d\n", GET_SEX(ch));

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

Time to create page: 0.351 seconds