login screen, greeting ansi

Posted by Ithildin on Sun 02 Mar 2003 08:45 AM — 33 posts, 127,710 views.

USA #0
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

Australia Forum Administrator #1
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.
USA #2
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
USA #3
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
Amended on Tue 04 Mar 2003 04:37 AM by Ithildin
Australia Forum Administrator #4
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

USA #5
hey, i couldn't get this to work. i must be doing something wrong

sorry for being incompetent sometimes
Ithildin
Australia Forum Administrator #6
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?
USA #7
hey, i found out that i have to use  for it to work. thanks for the help though.
#8
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.
Amended on Mon 27 Oct 2003 12:53 AM by Kalmah
USA #9
You need to have the proper escape codes, in raw ANSII. If you literally entered "^[" it won't work.
#10
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.
Amended on Mon 27 Oct 2003 02:14 AM by Kalmah
USA #11
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
#12
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.
USA #13
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. :)
#14
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. :-)
USA #15
You only have those colors, I believe.. (see Nick's post), but, what you CAN do is set the bold attribute. Most MUD clients consider "bold" to be the "light" version of the color.

To do this:

[0;1;37m

Note the added 1. That means "bold" (or "bright").

I'm glad that it's all sorted out now. :)
#16
Thanks again. You have been a great amount of help to me.

:-)
#17
Where can I get VI? :P
United Kingdom #18
I manged to get  to display color, just change the number before the m to one of the ones nick said and it should work a treat it works on my greet msg (the one that displays as soon as u connect to a mud) Hope that helps...

Rash

P.S: I think VI is apart of Cygwin and i know its on the Wolfpaw Hostiing Shell's dont know about anything else sorry
USA #19
Geez people... vi is a standard text editor that comes with most implementations of Unix. Cygwin is not some magic, random program, but is instead an "implementation" of Unix on Windows that creates a sort of virtual Unix environment for programs to run in, and also includes most Unix libraries. It's a sort of emulator.

You guys should do more research on what it is you're doing if you want to understand what's actually going on. :)

In other words, you don't just go "get" vi. You need a Unix environment first, and most come with vi anyways. With Cygwin, you need to remember to install the vi editor.
USA #20
Actually, there are versoins of vi available for download that are tweaked to run in windows. However, for those that need a good low end (read free) text editor for windows that won't completely muck up *nix formatting, I'd recommend metapad from www.liquidninja.com
#21
This is a pretty niffty program. Thanks. :)
#22
What are the basic commands to use VI? I want to add color to my login screen. :p

==EDIT== nvm I found one. :p Ok I still need help I type vi help.are and it didn't work it showed nothing except these: ~. Any help? :/
Amended on Tue 25 Nov 2003 10:14 PM by USER007
USA #23
There are tons of manuals for vi. Just search on google.

As for why you have ~s, that's probably because the twiddle is the line-end marker. Why your file only has those, is another problem, that most likely has nothing to do with vi.
#24
==EDIT== One of my friends told me so ignore this post.
Amended on Thu 27 Nov 2003 12:44 AM by USER007
#25
hrm, out of curiosity, what are the drawbacks to hardcoding ansi into the login screen?
also, are there many clients that don't support ansi color?
USA #26
There may be some clients out there that don't support ANSI, but not many.

One of the main problems is that there are people who don't want color. And you'd be forcing color on to them.
Canada #27
Easiest way is to ask if they want color before you display the greeting. There's a snippet for it on Samson's page, I think.
USA #28
Most clients should support ansi. Ansi is a part of the standard so, if you are writting a client, you should include ansi. Hell, even telnet is ansi enabled. Plus forcing the color should have no effect on non-ansi clients and no effect on performance. I guess the point i am trying to make is that your client should have color and your users should use color, and plus they are given the option to turn it off anyway.
Australia Forum Administrator #29
Quote:

Where can I get VI?


Vim (VI Improved) is available from:

http://www.vim.org/

There is a stand-alone Windows version, I think.
Australia Forum Administrator #30
Quote:

There may be some clients out there that don't support ANSI, but not many.


To be honest, these days when people have megabytes of RAM and gigabytes of disk, I doubt many would use a telnet program that doesn't at least support ANSI colours in some way.

Quote:

One of the main problems is that there are people who don't want color. And you'd be forcing color on to them.


If this really worries them, I think they could simply define a colour palette of grays etc. and not see the colours.
USA #31
Quote:
If this really worries them, I think they could simply define a colour palette of grays etc. and not see the colours.

True, but what would a typical user do first when finding this on a new MUD they're trying? Setup the palette, or leave the MUD and look for another?
USA #32
That's assuming that user is so bothered by the colors that it puts them off to the point where they'd want to go to another MUD. Like Nick said, you'd be pretty hard pressed to actually find a client these days that doesn't have ANSI support.