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.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ The Who List
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Malti
USA (55 posts) Bio
|
| Date
| Tue 02 May 2006 01:29 AM (UTC) |
| Message
| I have been on several MUDs (good ones are hard to find these days) and I have realized that many of them have formatted who lists. What I mean by this is that everything is spaced nicely. I decided I want to do the same thing, but I am stuck...
I want this format
[ lvl Class ] Name Title and all that other info
[ lvl Class ] Name Title and all that other info
There is a problem in the fact that the classes and level strings can be different lengths. I have changed the following.
snprintf( class_text, MAX_INPUT_LENGTH, "[ %s%2d %s ]", NOT_AUTHED( wch ) ? "N" : " ", wch->level,
class_table[wch->Class]->who_name );
This generates what I want, except it is based off of how long the class and level strings are. Is there a way I can make it a standard length so no matter what class, race, etc. it will all be uniformed with the braces?
| | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #1 on Tue 02 May 2006 01:35 AM (UTC) |
| Message
| | You can use %10s to format all strings as width 10, but that'll use more than you need. What you might have to do to get it "right" is to store all your lines in memory, and then count the widest one; once you have that widest entry, you can format everything to that width. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Zeno
USA (2,871 posts) Bio
|
| Date
| Reply #2 on Tue 02 May 2006 01:35 AM (UTC) |
| Message
| | Yes, you would use formatting. I'm trying to think of the man page. I think it's one of the printf pages... I'm not sure. An example would be using %5s, %-5s, and so on. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | | Top |
|
| Posted by
| Malti
USA (55 posts) Bio
|
| Date
| Reply #3 on Tue 02 May 2006 02:00 AM (UTC) |
| Message
|
I used that and It works prefectly. Thanks very much for your help! | | 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.
14,706 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top