>>i know this is a newbie question, but i have been trying to redo the
>>do_score & do_who for sometime. I have added races in. which thats what i
>>am trying to add to both of these commands or atleast the who command.
>> In do_score i have been trying to edit it so when you type score it looks
>> like this:
>>
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>| HitPoints: Mana: Move: Age: |
>>| MaxHit: MaxMana: MaxMove: Race: |
>>| |
>>| PlayersName: Ac: XP: Gold: |
>>| Class: Level: XPtoLvl: |
>>| |
>>| STR: DEX: WIS: INT: CON: CHR: |
>>| |
>>| { Name mud HERE} |
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>This is too lame...Look at the current do_score, and just add some
>spaces and shit in it...read a C book, specifically the printf function,
>sprintf being the same but using a buffer...
>
Come now, not everyone has the time to learn C, and some people are just
not good at programming and other mathematical things. That doesn't mean he
couldn't run a decent MUD, perhaps he is very creative or what not.
>I'll even step you through the first line...
>
>>| HitPoints: Mana: Move: Age: |
>sprintf( buf, "| HitPoints: %4d Mana: %4d Move: %4d Age: %4d |\r\n",
>GET_HIT( ch ), GET_MANA( ch ), GET_MOVE( ch ), GET_AGE( ch ));
>
>Look in utils.h for the defines...
Original Poster:
I'll break this down for you. The way CircleMUD displays text to a character
is by writing it to a buffer (buf is the most common, sometimes it uses
buf2, etc) and then using the function send_to_char. the function sprintf()
writes
something to a buffer. So:
sprintf(buf, "Hello!"); /* always remember the ; on functions */
send_to_char(buf, ch);
Would send "Hello!" to the character (ch). A simpler way would be:
send_to_char("Hello!", ch);
Unfortunately, send_to_char cannot be used to display variables inside
a string of text, for this we must use sprintf like so..
sprintf(buf, "Hit Points: %d", GET_HIT(ch));
send_to_char(buf, ch);
GET_HIT is called a macro, something defined in the code that you can use
instead of typing out the entire variable.
I hope this helps.
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST