[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  swr1fuss prompt problems

swr1fuss prompt problems

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Asean Novari   USA  (82 posts)  [Biography] bio
Date Fri 25 Feb 2005 12:29 AM (UTC)
Message
On the default_prompt when i enter a command the command gets
either entered on the next line or after all the text on that
line..
but as soon as i enter in my own customized prompt it gets
entered a new line and it makes some of the last characters
for my prompt warp to the next line with it..

is there a way to fix this..

also is there a way to add a empty line after the prompt and
still have it be a mud feature rather than a plugin..



[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #1 on Fri 25 Feb 2005 12:35 AM (UTC)
Message
If you want someone to be able to add a line break where they want, you can use this, put it in display_prompt as one of the options, then use %_ to add a new line
                        case '_':
                                mudstrlcpy(pbuf, "\n\r", MSL);
                                break;

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Asean Novari   USA  (82 posts)  [Biography] bio
Date Reply #2 on Fri 25 Feb 2005 01:10 AM (UTC)

Amended on Fri 25 Feb 2005 01:11 AM (UTC) by Asean Novari

Message
I see a display_prompt in comm.c but I dont get where to put in what you said.. and does indenting matter?

*edit*
shoots self in head as he locates place to insert code..



[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #3 on Fri 25 Feb 2005 01:10 AM (UTC)
Message
You can add the case with all the other cases, like:
case 'h'


No indenting doesn't really matter.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Asean Novari   USA  (82 posts)  [Biography] bio
Date Reply #4 on Fri 25 Feb 2005 01:16 AM (UTC)

Amended on Fri 25 Feb 2005 01:18 AM (UTC) by Asean Novari

Message
$ make
make -s swreality
Compiling o/comm.o....
comm.c: In function `display_prompt':
comm.c:2890: warning: implicit declaration of function `mudstrlcpy'
comm.c:2890: error: `MSL' undeclared (first use in this function)
comm.c:2890: error: (Each undeclared identifier is reported only once
comm.c:2890: error: for each function it appears in.)
make[1]: *** [o/comm.o] Error 1
make: *** [all] Error 2

thats what i get when its entered into the function

            switch ( *prompt )
            {
               case '_':
                  mudstrlcpy(pbuf, "\n\r", MSL);
                  break;
               case '%':
                  *pbuf++ = '%';
                  *pbuf = '\0';
                  break;


added code



[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #5 on Fri 25 Feb 2005 01:20 AM (UTC)
Message
Grevan was using a different codebase, so change:
mudstrlcpy(pbuf, "\n\r", MSL);

to:
        sprintf( pbuf, "\n\r" );

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #6 on Fri 25 Feb 2005 01:20 AM (UTC)
Message
Quote:
No indenting doesn't really matter.
*gasp!!* Never say that! We're doomed to have poorly indented code submitted for the rest of our lives now! :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #7 on Fri 25 Feb 2005 01:21 AM (UTC)
Message
I know, but I simply meant in terms of results. ;)

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #8 on Fri 25 Feb 2005 01:25 AM (UTC)

Amended on Fri 25 Feb 2005 01:27 AM (UTC) by Greven

Message
Thats what the wonderful program called indent is for, to change peoples poorly indented code to a format that you like, heh.

And I have mine set up as such, you need to put the check below the check for the % character, with the other special values. This is what I use:
                        case 'h':
                                pstat = ch->hit;
                                break;
                        case 'H':
                                pstat = ch->max_hit;
                                break;
                        case '_':
                                mudstrlcpy(pbuf, "\n\r", MSL);
                                break;
Since I'm using mudstrlcpy, you can just use strncpy instead, and it will produce the same result for your purposes.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Asean Novari   USA  (82 posts)  [Biography] bio
Date Reply #9 on Fri 25 Feb 2005 01:31 AM (UTC)

Amended on Fri 25 Feb 2005 01:33 AM (UTC) by Asean Novari

Message
Ok Thanks guys.. everythings working right now

*EDIT*
Heh.. now i see another prompt issue i would like help with..

On another mud i played you could look at your current prompt by just typing prompt.. how do i enter that in here as well?


please and thanks



[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #10 on Fri 25 Feb 2005 01:37 AM (UTC)
Message
You can use something like this:
    sprintf( buf, "%s\n\r", !str_cmp( ch->pcdata->prompt, "" ) ? "(default prompt)" : ch->pcdata->prompt );
    set_char_color( AT_WHITE, ch );
    write_to_descriptor( ch->desc->descriptor, "Your current prompt string:\n\r", 0 );
    write_to_descriptor( ch->desc->descriptor, buf, 0 );
    write_to_descriptor( ch->desc->descriptor, "Set prompt to what? (try help prompt)\n\r", 0 );
Should allow you to print out a characters prompt, including the color codes.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Asean Novari   USA  (82 posts)  [Biography] bio
Date Reply #11 on Fri 25 Feb 2005 01:54 AM (UTC)

Amended on Fri 25 Feb 2005 01:57 AM (UTC) by Asean Novari

Message
should i enter this in player.c where the "set prompt to what" text is currenty at?

void do_prompt( CHAR_DATA * ch, char *argument )
{
   char arg[MAX_INPUT_LENGTH];

   if( IS_NPC( ch ) )
   {
      send_to_char( "NPC's can't change their prompt..\n\r", ch );
      return;
   }
   smash_tilde( argument );
   one_argument( argument, arg );
   if( !*arg )
   {
      send_to_char( "Set prompt to what? (try help prompt)\n\r", ch );
      return;
   }
   if( ch->pcdata->prompt )
      STRFREE( ch->pcdata->prompt );

   if( strlen( argument ) > 128 )
      argument[128] = '\0';



or does it go someplace else.. like comm.c



[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #12 on Fri 25 Feb 2005 02:14 AM (UTC)
Message
You would put it in do_prompt. After looking at it, I don't like filtering my code as that, so I actually changed it to such
        if (!*arg)
        {
                if ( ch->desc && ch->desc->descriptor )
                {
                    sprintf( buf, "%s\n\r", !str_cmp( ch->pcdata->prompt, "" ) ? "(default prompt)" : ch->pcdata->prompt );
                    set_char_color( AT_WHITE, ch );
                    send_to_char("Your current prompt string:\n\r", ch );
                    ch_printf(ch, "%s\n\r", full_color(ch->pcdata->prompt));
                }
                send_to_char("Set prompt to what? (try help prompt)\n\r", ch);
                return;
        }

char     *full_color(char *str)
{
        static char ret[MAX_STRING_LENGTH];
        char     *retptr;

        retptr = ret;
        for (; *str != '\0'; str++)
        {
                if (*str == '&')
                {
                        *retptr = *str;
                        retptr++;
                        *retptr = '&';
                        retptr++;
                }
                else
                {
                        *retptr = *str;
                        retptr++;
                }
        }
        *retptr = '\0';
        return ret;
}

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Asean Novari   USA  (82 posts)  [Biography] bio
Date Reply #13 on Fri 25 Feb 2005 02:29 AM (UTC)
Message
this dosent work with swr1fuss .. i get this error

Administrator@Home ~/swr1fuss/src
$ make
make -s swreality
  Compiling o/player.o....
player.c: In function `do_prompt':
player.c:1150: error: `buf' undeclared (first use in this function)
player.c:1150: error: (Each undeclared identifier is reported only once
player.c:1150: error: for each function it appears in.)
player.c:1153: warning: implicit declaration of function `full_color'
player.c:1160: warning: `full_color' was declared implicitly `extern' and later `static'
player.c:1153: warning: previous declaration of `full_color'
player.c:1160: warning: type mismatch with previous implicit declaration
player.c:1153: warning: previous implicit declaration of `full_color'
make[1]: *** [o/player.o] Error 1
make: *** [all] Error 2



[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #14 on Fri 25 Feb 2005 02:32 AM (UTC)
Message
Out of curiosity do you understand the errors? Most of them are very basic and you should be able to figure them out on your own - trust me, it'll do you service in the long run.

Also isn't the ability to display the prompt by just typing 'prompt' in by default?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


40,543 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]