Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ login screen, greeting ansi

login screen, greeting ansi

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


Pages: 1 2  3  

Posted by Ithildin   USA  (262 posts)  Bio
Date Sun 02 Mar 2003 08:45 AM (UTC)
Message
i'm trying to get color into my greeting. after reading the faq about it i'm still kind of stumped. here's what it said to do.

12d) I want to add color to the initial login screen, before players enter
their names.

This one is tough, because they won't have a character yet. You will also
need to add another CON_ state to ask whether or not they would like ANSI
color before the screen is displayed, and a bool to DESCRIPTOR_DATA to
record their answer. Probably the easiest would be to create a dummy character in
nanny(), such as the following:

CHAR_DATA dummy;

if (!d->character)
{
memset(&dummy, 0, sizeof(dummy));
d->character = &dummy;
dummy.desc = d;
if (d->ansi) /* The bool mentioned above */
SET_BIT(dummy.act, PLR_ANSI);
}

You can then replace all the write_to_buffer()s with send_to_char_color()s
in nanny(), the same as was done in act() in 12a.
** Make sure you NULL-terminate all your strings before you
send_to_char_color() them. The one in act() was NULL-terminated previously,
but there may be some in nanny() which aren't.


i've tried messing with this and still haven't came up with much. i tried putting the CON_GET_WANT_RIPANSI into the login, but it didn't work. i also don't really understand the bool part. the descriptor_data is kind of weary too, but i just put DESCRIPTOR_DATA *ansi in mud.h and it did alright.

so if anyone can help me, that'd be great. i'm makin leaps and bounds in my C++ learning still just have a few more unsolved questions is all. i figure what better way then to ask all you nice people out there.

THanks so much for your help,
Ithildin

Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 04 Mar 2003 01:53 AM (UTC)
Message
If you are going to send colour anyway, before you know if they can use it or not, why not just put the colour codes in the initial screen? Then it can just be sent "as is" without any code changes.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #2 on Tue 04 Mar 2003 03:50 AM (UTC)
Message
i'm not sure how to make it all color. maybe i'm looking over something that's staring right at me. i've tried just changing write_to_buffer to send_to_char_color and it didn't work. so i'm not sure what's goin on. i've been setting up a snippet from

http://islands.freehosting.net/color_greeting.txt

i changed everything to fit my smaug code, but when logging in it would just show:

Do you want ANSI? (Y/N)when putting in Y, it would go straight to my name, which i saw was CON_GET_NAME in the snippet, i messed with that moving it around. i never got the greeting screen to come up it would always error.

so if it's just easier to set colors to the whole thing without asking for it, then by all means please help me. hehe.

Thanks,
Ithildin
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #3 on Tue 04 Mar 2003 04:35 AM (UTC)

Amended on Tue 04 Mar 2003 04:37 AM (UTC) by Ithildin

Message
here's what i was tryin.

case CON_ANSI:
		
		if ( argument[0] == '\0' || UPPER(argument[0]) == 'y' )
	        {
            d->ansi = TRUE;
           //send_to_char_color( "&Y&WAnsi enabled!&w\n\r" , 0 );
            //d->connected = CON_GET_NAME;

		    {
                extern char * help_greeting;
                if ( help_greeting[0] == '.' )
                  send_to_char_color( help_greeting+1, 0 );
                else
                  send_to_char_color( help_greeting, 0 );
            }
			d->connected = CON_GET_NAME;
           	 break;
			 
        }

        if (UPPER(argument[0]) == 'n')
        {
            d->ansi = FALSE;
            //send_to_char_color("Ansi disabled!\n\r", 0);
            
			//d->connected = CON_GET_NAME;
            {
                extern char * help_greeting;
                if ( help_greeting[0] == '.' )
                  send_to_char_color( help_greeting+1, 0 );
                else
                  send_to_char_color( help_greeting , 0 );
            }
			d->connected = CON_GET_NAME;
            break;
			
        }
        else
        {
            send_to_char_color("Do you want ANSI? (Y/n) ",0);
            return;
        }


what would happen is:

Do you want ANSI? Y
Bug send_to_char_color: NULL *ch
*press enter*
Bug send_to_char_color: NULL *ch
Ithildin
password:

and then i'm able to connect

so what i'm tryin to get at is, if you enter Y or just *enter*, it will send you into the colored greeting screen. but tha'ts what it shows and the greeting doesn't even come up. but i'm gettin kinda frustrated with it, so if there is a way to just send color to all, then i'm all for it.

thanks heaps
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 04 Mar 2003 05:37 AM (UTC)
Message
What I mean is, throw out all your code changes relating to this problem, go back to standard code.

Then, edit help.are file (in the area directory), scroll down to the GREETING topic (line -1 GREETING~) and add the ANSI codes directly.

eg. I did this at line 4871:


SMAUG 1.4 written by ^[[31mThoric^[[36m (Derek Snider) with Altrag, Blodkai, Haus, Narn,
Scryn, Swordbearer, Tricops, Gorog, Rennard, Grishnakh, Fireblade and Nivek.


The ^[ character is an "escape" character that you can type in, in various ways. I used "vi" editor, so I pressed "i" to go into input mode, then Ctrl+V to quote the next character, and then typed the escape key.

You just need to look up the ANSI codes for various colours then, here are some examples:


Enter ESC [xm (Escape character, followed directly by [ followed by a number, followed by lower-case "m").

The numbers can be:

Foreground colour

30 black
31 red
32 green
33 yellow
34 blue
35 magenta
36 cyan
37 white

Background colour

40 black
41 red
42 green
43 yellow
44 blue
45 magenta
46 cyan
47 white

Others

0 - reset to default
1 bold
3 blink
4 underline
7 inverse

22 not bold
23 not blink
24 not underline
27 not inverse


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #5 on Fri 07 Mar 2003 06:49 AM (UTC)
Message
hey, i couldn't get this to work. i must be doing something wrong

sorry for being incompetent sometimes
Ithildin
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #6 on Sat 08 Mar 2003 08:33 PM (UTC)
Message
Yes, but what?

Did you edit the help.are file as I suggested, and reboot the server? Did you key in the ESC key into the help.are file successfully? How did you do that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #7 on Wed 12 Mar 2003 07:05 AM (UTC)
Message
hey, i found out that i have to use  for it to work. thanks for the help though.
Top

Posted by Kalmah   (17 posts)  Bio
Date Reply #8 on Mon 27 Oct 2003 12:24 AM (UTC)

Amended on Mon 27 Oct 2003 12:53 AM (UTC) by Kalmah

Message
I thought I might bring this subject back up since I'm having some problems with it.

So you're saying that I can add those codes to the help
file and it will automatically show color (if the players client supports it) without any code changes?

This is what the greeting part of my help.are looks like.


-1 GREETING~
.^[[37m                      /\ ^[[36m                     
 ^[[37m                     /# \         ^[[36m        
  ^[[36m                   /### \    /\  ^[[36m
  ^[[37m                  /   ###\  /##\ ^[[36m
^[[35m      /\           /    ## # /##\/\     ^[[36m
^[[35m     / #\         / /  /      /   # /#\ ^[[36m
^[[32m    /  ##\  /\/// //  /\  /    _/  /  #\
         /###   \# //  /   /   \      / /    #\    /\
        / //###  \# \/    / ## \   / /   _  / {  \ /# \
      `--`----`-`-== `-`= == -- -=`=-`````-- =' ==`---- ^[[36m

SMAUG 1.4 written by Thoric (Derek Snider) with Altrag, Blodkai, Haus, Narn,
Scryn, Swordbearer, Tricops, Gorog, Rennard, Grishnakh, Fireblade and Nivek.


When the mud boots I get no color. And It also displays the codes around it. Am I missing something?

I appreciate it.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #9 on Mon 27 Oct 2003 01:59 AM (UTC)
Message
You need to have the proper escape codes, in raw ANSII. If you literally entered "^[" it won't work.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Kalmah   (17 posts)  Bio
Date Reply #10 on Mon 27 Oct 2003 02:12 AM (UTC)

Amended on Mon 27 Oct 2003 02:14 AM (UTC) by Kalmah

Message
Thanks for your reply.

I obviously have no idea what I'm doing. hehe
I've just been going back and forth between trying
to install code snippets and reading my c++ manual
to learn as much as I can this last week. Even though
I believe smaug is written in c. But I'm guessing
I should be able to understand c enough to be proficient
in it by learning c++.

Anybody know of a newbie all around guide to smaug?
I've read through all the documents that came with it but I need things spelled out to me in english it seems. hehe

I hate having to ask other people how to do stuff. I just don't have enough knowledge to be able to troubleshoot stuff on my own yet.

I have no idea what you mean by an 'escape code' by the way. :-)

I appreciate it.

EDIT: I guess I might add that I've tried 4 different snippets to make it ask if the player wants ansi color before the greeting screen but couldn't get any of them to work. That is a possible alternative I wouldn't mind using.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #11 on Mon 27 Oct 2003 04:46 AM (UTC)
Message
If you know C++, C should be fine, even if you'll probably be very frustrated by the fact that many features don't exist in C (such as the standard template library, passing by reference, etc.) I've ported two MUD codebases to C++ now (one based on SMAUG 1.0 and one based on SWR: LOTJ - a Star Wars MUD) and I have to say, I find it soooo much nicer to work in.

Anyways, an escape code, or escape sequence, is basically a special character or set of characters that is meant to tell the telnet client something like: "what I send next is not normal text, but it's a special instruction." For example, take color changing. Before you send "37", which is an ASCII color code, you need to tell the client "the next thing I'm sending you is a color code".

Note: it's actually a little more complicated than this. You're actually sending things like telnet display options, which can handle much more than just color.

Nick gives a very good way of entering this character:
Quote:
The ^[ character is an "escape" character that you can type in, in various ways. I used "vi" editor, so I pressed "i" to go into input mode, then Ctrl+V to quote the next character, and then typed the escape key.

This only works of course if you're on a Unix environment (or Cygwin.) I can't think of any way to enter the character manually in Windows. You could always open up the text file with a hex editor and enter the proper hex code for the escape character. . . :)

I've never heard of an all-around guide. I'm assuming that you mean a guide to the code structure. I don't think any such thing exists, and as evidence I hold the fact that there is redundancy in the code and different coders write their own functions to do the same thing. hhandler.c has a lot of this... various ways of finding things in lists. Another example is that magic.c often implements its own methods of doing things like emptying objects, when you have an empty_obj function that does just that. Anyways, I don't think that such a thing exists, but then again, I haven't spent more than 15 minutes looking for it.

I suppose it could be useful to write such a thing, but personally I don't think it's worth it. SMAUG is getting a little old, and there is so much more potential and power opening up. I don't think it's worth the investment to document SMAUG, when the major mud code bases are probably going to be slowly moving towards other things anyways. (Then again, maybe not... we'll see in a few years. :P) I'm glad to answer questions though, if I have the answer. :)

Can't help with the snippets since I don't know:
a) what the snippets do
b) how they do it
c) how you put them in
d) how they don't work

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Kalmah   (17 posts)  Bio
Date Reply #12 on Mon 27 Oct 2003 05:12 AM (UTC)
Message
Thanks alot for the good information you gave me.

I thought I might have had it figured out. But it appears I don't.

I opened help.are in wordpad. Removed the '^'s from it.
Then opened up cygwin, then opened help.are in vi.
I then went to the line it was on and put '^' where they supposably belong. Then typed 'ZZ' to save and exit.

I must be mis-understanding something. That's ok. I might start a new thread and post that snippet for adding a question if you want ansi color before everything else comes up. Allthough I'm not sure if it would be easier to figure that out or this.

I appreciate it.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #13 on Mon 27 Oct 2003 05:27 AM (UTC)
Message
Oh, you actually need to enter the actual escape code - using the escape key. After you press control-v, press the escape key (on the keyboard), which then puts out ^[ to indicate that an escape code is there. Then you put the [37m after it.

You may want to put [0;37m ... the 0 clears the previous display setting and is good for avoiding color bleeding.

Sorry for not being clearer on that the first time around. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Kalmah   (17 posts)  Bio
Date Reply #14 on Mon 27 Oct 2003 05:53 AM (UTC)
Message
Excellent. It worked perfectly. I just need to make some changes to the colors I used. hehe

I'm also wondering if other variations of the colors are an option? Like for instance 32 is green, but can I use
light green?

Thanks a bunch. :-)
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.


90,220 views.

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

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

Go to topic:           Search the forum


[Go to top] top

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