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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ sprintf in score

sprintf in score

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


Posted by Ithildin   USA  (262 posts)  Bio
Date Thu 08 Apr 2004 07:58 AM (UTC)

Amended on Thu 08 Apr 2004 08:00 AM (UTC) by Ithildin

Message
here's my output of two different scores:

Mortal:

Hit Points : 687/ 687   Str: 18/ 15   Save vs Spell             :  0
Move Points: 945/ 945   Wis: 17/ 17   Save vs Breath Weapon     :  0
Size       : Medium      Con: 15/ 15   Save vs Pertri/Polymorpth :  0
Xp Needed  : 5520        Int: 13/ 17   Save vs Rod/Staff/Wand    :  0
Xp Current : 5450        Dex: 14/ 17   Save vs Para/Poison/Dmagic:  0


immortal:

Hit Points : 1000/ 1000  Str: 15/ 15   Save vs Spell             :  0
Move Points: 1240/ 1240  Wis: 13/ 13   Save vs Breath Weapon     :  0
Size       : Medium      Con: 12/ 12   Save vs Pertri/Polymorpth :  0
Xp Needed  : 9175        Int: 14/ 13   Save vs Rod/Staff/Wand    :  0
Xp Current : 0           Dex: 14/ 13   Save vs Para/Poison/Dmagic:  0



as you can see, the STR and Wis are off by a space when the hp is less than a thousand. how can i get it to stay in one spot and not move according to the spaces filled by the hundreds and thousands? here's my code


pager_printf_color(ch, "\n\r&cHit Points &z: &g%d&z/ &G%-5d &cStr: &g%d&z/ &G%-3d  &gSave vs Spell             &z:  &g0", ch->hit, ch->max_hit, get_curr_str(ch), ch->perm_str);
	pager_printf_color(ch, "\n\r&cMove Points&z: &g%d&z/ &G%-5d &cWis: &g%d&z/ &G%-3d  &gSave vs Breath Weapon     &z:  &g0", ch->move, ch->max_move, get_curr_wis(ch), ch->perm_wis);
	pager_printf_color(ch, "\n\r&cSize       &z: &gMedium      &cCon: &g%d&z/ &G%-3d  &gSave vs Pertri/Polymorpth &z:  &g0", get_curr_con(ch), ch->perm_con);
	pager_printf_color(ch, "\n\r&cXp Needed  &z: &g%-11d &cInt: &g%d&z/ &G%-3d  &gSave vs Rod/Staff/Wand    &z:  &g0", exp_level(ch, ch->level+1), ch->perm_int);
	pager_printf_color(ch, "\n\r&cXp Current &z: &g%-11d &cDex: &g%d&z/ &G%-3d  &gSave vs Para/Poison/Dmagic&z:  &g0", ch->exp, ch->perm_dex);
	


how would i go about making it stay in line?

Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 08 Apr 2004 10:57 PM (UTC)
Message
You need to specify a width for each number. It is there for most except the first.


pager_printf_color(ch, "\n\r&cHit Points &z: &g%d&z/ &G%-5d


See where the 2nd one has %-5d ? That means "allow 5 spaces for the number". However the first one (the one I put in bold) is missing the "-5" bit.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


11,704 views.

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.