sprintf in score

Posted by Ithildin on Thu 08 Apr 2004 07:58 AM — 2 posts, 12,780 views.

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

Amended on Thu 08 Apr 2004 08:00 AM by Ithildin
Australia Forum Administrator #1
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.