About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Wed May 25, 2011 2:15 pm   

Equal Spacing
 
I'm trying to make a custom scorecard for myself, but only for combat statistics.

The default scorecard on the MUD I play looks like this:
Code:

Player Information for: Perrin Goldeneyes
  Hours Played:      1,140      Age:            14 years (Born 9/14/1440)
  Class Level:        60        Total Level:    180
  Race:               half-elf  Gender:         male
  Class:           priest       Alignment:      -744 (+demonic)
  Hit Points:       1709/1709   Practices:      0
  Spell Points:     1342/1342   Quest Points:   20,078 (458 quests, 464 failed)
  Stamina:          1553/1553   Reputation:     100 (Saint)
  Strength:           22/22     Vitality:       19/19
  Knowledge:          18/19     Luck:           17/19
  Wisdom:             21/21     Courage:        16/20
  Agility:            22/22     Sanity:         20/20
  Personality:        12/19


I cut off the unnecessary parts. Anyway, here's what I have now on mine:
Code:


Combat Information for all sessions starting:
Defensive Statistics:
. Dodge:0 Acrobatics:0
. Shield Block:0 Parry:0
. Magical Fade:0
*You have used a proficiency-based defense 0 times and been hit 0 times, with a defense rate of 0%.
*You have evaded 0 attacks.
Offensive Statistics:
. Pierce:0 Bash:0
. Slash:0 Exotic:0
*You have landed 0 pierce attacks and missed 0 times with an accuracy of 0%.
*You have landed 0 bash attacks and missed 0 times with an accuracy of 0%.
*You have landed 0 slash attacks and missed 0 times with an accuracy of 0%.
*You have landed 0 exotic attacks and missed 0 times with an accuracy of 0%.
*You have landed 0 backstabs and missed with0 backstabs, with a success rate of 0%.
*You have landed 0 total attacks and missed a total of 0 times with an overall accuracy of 0%.


I'd like to be able to take the periods away, for one, that come before Dodge, Shield Block, Magical Fade, Pierce, and Slash while maintaining the spacing on them.

Also, I'd like Dodge and Acrobatics, Parry and Shield Block, Pierce and Bash, and Slash and Exotic to be equidistant from one another regardless of their values. Like the official/default MM scorecard has with the statistics. So regardless of whether Parry has a value of 10 and dodge has a value of 1000, I want them to be able to line up.

Is this possible? And if it is, how? :x

Btw, everything is a 0 because I haven't done that part yet. :D Don't need help with it, just the spacing issue.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed May 25, 2011 2:38 pm   
 
If the period is part of the captured element, you should be able to do a %replace with it and replace it with a space.

If it's something you add there to get the spacing you want, take a look at %format instead. You can format spaces before and after your strings.
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Wed May 25, 2011 3:03 pm   
 
It's something I put there for spacing, because just using spaces doesn't work. How would I use %format for that purpose? I'm rather dense.

Also, do you have any idea how to achieve the spacing I'm looking for with the others? Like, if you look at the first score card, the spacing between Hitpoints and Practices remains the same regardless of whether Hitpoints is 50/50(and thus 5 characters total) or 1700/1700(and 9 characters). For instance, "Practices" is always 32 spaces from the beginning of the line, no matter what's in frnt of it. Know what I mean?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed May 25, 2011 5:03 pm   
 
Well, to be honest, I should have mentioned %repeat first, since you can do %repeat(" ", 15) to start something 15 spaces in.

However, %format is very useful for setting it up like your score card. I'll give a brief tutorial on how to do it.

Let's say that your columns are 50 characters long, and you want all text to be left-justified. You would then use:

Code:
%format("&-50s", "string of text you want here")


What that will do is ensure that no matter how long the string of text is, the trailing spaces will keep the column width at 50. An example:

Code:
#say {| %format("&-50s","This is a long string of text.")|}
#say {| %format("&-50s","This is an even longer string of text.")|}


will return:

Code:
| This is a long string of text.                    |
| This is an even longer string of text.            |


To get even more advanced (making things into two columns:

Code:
#say {| %format("&-50s | &-50s","This would be the first column.","This would be the second column.")|}


will return:

Code:
| This would be the first column.                    | This would be the second column.                  |


Play around with it, see what you can come up with. If you need more help, I'll try to help you out.
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Wed May 25, 2011 6:32 pm   
 
Did you mean to use code instead of quote? :x I think you might have and it took your spaces away. I'll try the formatting. repeat worked great to replace the periods, though. :) Thanks.


Edit: You fixed it. That's what happened when you don't reload a page for 2 hours. -_-
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Wed May 25, 2011 6:40 pm   
 
Code:

Location Accuracy:
  Head:3 Torso:48
  Arms:0 Legs:3
  Tail:9 Wings:0
*You are currently aiming for your opponents' torso.


^This is what it's looking like for me right now.

Code:

Location Accuracy:
  Head:   3               Torso:  48
  Arms:   0               Legs:   3
  Tail:   9               Wings:  0
*You are currently aiming for your opponents' torso.


^This is what I want it to look like. Notice how the columns line up and so do the numbers.

Code:

#echo %repeat(" ",2)%ansi(bright,blue)Head:%ansi(white)@headhit %ansi(bright,blue)Torso:%ansi(white)@torsohit
#echo %repeat(" ",2)%ansi(bright,blue)Arms:%ansi(white)@armhit %ansi(bright,blue)Legs:%ansi(white)@leghit
#echo %repeat(" ",2)%ansi(bright,blue)Tail:%ansi(white)@tailhit %ansi(bright,blue)Wings:%ansi(white)@winghit
#echo %ansi(yellow)*%ansi(bright,blue)You are currently aiming for your opponents' %ansi(white)@comaim%ansi(bright,blue).


That's my current script.

I don't meeaaan to make you do it for me, but using %format, how would I achieve this?

Edit: Uhh, hold on. Might have it. Didn't even think about using a space.

Edit2: Nvm, I dunno wtf I'm doing. Lol.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed May 25, 2011 7:58 pm   
 
Code:
#say {%repeat(" ",2)%format("&25s  &25s",%concat(%ansi(bright, blue),"Head:", %ansi(white),%format("&5s",@headhit)),%concat(%ansi(bright, blue),"Torso:", %ansi(white),%format("&5s",@torsohit)))}


That'll probably give you more what you want. You can mess around with the numerical aspects of it, but you will probably get the hang of it shortly.
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Wed May 25, 2011 10:11 pm   
 
That works great. I modified it a little though because the values for torsohit and all of those weren't showing up for some reason. Here's what I have:

Code:

#echo {%format("&35s &35s",%concat(%ansi(bright, blue),"Head:", %ansi(white),%repeat(" ",5)@headhit),%concat(%ansi(bright, blue),"Torso:",%ansi(white),%repeat(" ",4)@torsohit))}
#echo {%format("&35s &34s",%concat(%ansi(bright, blue),"Arms:", %ansi(white),%repeat(" ",5)@armhit),%concat(%ansi(bright, blue),"Legs:",%ansi(white),%repeat(" ",4)@leghit))}
#echo {%format("&35s &34s",%concat(%ansi(bright, blue),"Tail:", %ansi(white),%repeat(" ",5)@tailhit),%concat(%ansi(bright, blue),"Wings:",%ansi(white),%repeat(" ",4)@winghit))}


The spacing is perfect with those settings, BUT. When one of them gorws to have another digit, the spacing is thrown off. Observe:

Code:

Location Accuracy:
    Head:     0     Torso:    0
    Arms:     0      Legs:    0
    Tail:     0     Wings:    0
*You are currently aiming for your opponents' torso.


Perfect, no? And now....

Code:

Location Accuracy:
    Head:     0    Torso:    14
    Arms:     0      Legs:    0
    Tail:     1     Wings:    1
*You are currently aiming for your opponents' torso.



Notice "Torso:" got bumped back one because the value went to the double digits. As you would logically assume, the same happens when you get into the 100's and 1000's. Any idea how I can fix that?

Edit: Maybe it has to do with needing to be left aligned? Seems like it should already be, though. >.> I'll check. If I can remember how.

Edit2: Once again, I have no idea wtf I'm doing. That didn't work at all.

Edit3: Ok. Changed it.

Script:
Code:

#echo %ansi(bright,blue)Location Accuracy:
#echo {%repeat(" ",5)%format("&-35s &35s",%concat(%ansi(bright, blue),"Head:", %ansi(white),%repeat(" ",5)@headhit),%concat(%ansi(bright, blue),"Torso:",%ansi(white),%format("&6s",%concat(@torsohit))))}
#echo {%repeat(" ",5)%format("&-35s &35s",%concat(%ansi(bright, blue),"Arms:", %ansi(white),%repeat(" ",5)@armhit),%concat(%ansi(bright, blue),"Legs:",%ansi(white),%format("&6s",%concat(@leghit))))}
#echo {%repeat(" ",5)%format("&-35s &35s",%concat(%ansi(bright, blue),"Tail:", %ansi(white),%repeat(" ",5)@tailhit),%concat(%ansi(bright, blue),"Wings:",%ansi(white),%format("&6s",%concat(@winghit))))}
#echo %ansi(yellow)*%ansi(bright,blue)You are currently aiming for your opponents' %ansi(white)@comaim%ansi(bright,blue).


Which gets me:
Code:

Location Accuracy:
    Head:     0     Torso:
    Arms:     0      Legs:
    Tail:     1     Wings:
*You are currently aiming for your opponents' torso.




HOLY CRAP MORE EDIT:
Moved the final "%format" to the left of "%ansi(white)" and the numbers show up. Still not aligned where I want them, though.
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Thu May 26, 2011 12:01 am   
 
Ok. Here's my current script:

Code:

#echo %ansi(bright,blue)Location Accuracy:
#echo {%repeat(" ",2)%format("&-35s &30s &-5s",%concat(%ansi(bright, blue),"Head:", %ansi(white),%repeat(" ",9)@headhit),%concat(%ansi(bright, blue),"Torso:"),%repeat(" ",3)%concat(%ansi(white),@torsohit))}
#echo {%repeat(" ",2)%format("&-35s &30s &-5s",%concat(%ansi(bright, blue),"Arms:", %ansi(white),%repeat(" ",9)@armhit),%concat(%ansi(bright, blue),"Legs:"),%repeat(" ",3)%concat(%ansi(white),@leghit))}
#echo {%repeat(" ",2)%format("&-35s &30s &-5s",%concat(%ansi(bright, blue),"Tail:", %ansi(white),%repeat(" ",9)@tailhit),%concat(%ansi(bright, blue),"Wings:"),%repeat(" ",3)%concat(%ansi(white),@winghit))}
#echo %ansi(yellow)*%ansi(bright,blue)You are aiming at your opponents' %ansi(white)@comaim%ansi(bright,blue).


That's working the best right now. The only problem at this point is the values of Head, Arms, and Tail. They're bumping Torso, Legs, and Wings one space to the right every extra digit.

Code:


Location Accuracy:
  Head:         0               Torso:    1000
  Arms:         1000                Legs:    1000
  Tail:         1000               Wings:    0
*You are aiming at your opponents' head.


You'll notice that Torso now stays where it should, but, as mentioned, Legs and Wings get bumped right by the values of Arms and Tail. I'd like that to not happen. :(
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Thu May 26, 2011 5:58 am   
 
Have you tried using multiple format functions on the line instead of trying to concat it all to fit the one format string? it allows you to better fine tune the spacing of each section... also, MXP color might make it easier to read the code.


Code:
#SAY {%repeat(" ",2)<color cadetblue>%format("&5s", "Head:")</color>%repeat(" ", 9)<color white>%format("&6.0n", @headHit)</color>}

and so on
_________________
Discord: Shalimarwildcat
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Thu May 26, 2011 5:16 pm   
 
I didn't use your code exactly, but it works great now. Thanks Shalimar and Charneus. :D Sorry for being a noob at this.

Next up: An even newbier question.
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Fri May 27, 2011 1:05 am   
 
Am I annoying you guys? I'm annoying myself quite badly.

Changed it up to simplify it and it's not very simple for me.

New script:
Code:

#echo {%repeat(" ",2)%ansi(bright,blue)%format("&5s", "Head:")%repeat(" ",3)%ansi(white)%format("&10.0n",@headhit)%ansi(bright,blue)"("%ansi(white)%eval(@headhit*100/@weaphits)"%"%ansi(bright,blue)")"%ansi(bright,blue)%format("&18s", "Torso:")%repeat(" ",3)%ansi(white)%format("&10.0n",@torsohit)%ansi(bright,blue)"("%ansi(white)%eval(@torsohit*100/@weaphits)"%"%ansi(bright,blue)")"}
#echo {%repeat(" ",2)%ansi(bright,blue)%format("&5s", "Arms:")%repeat(" ",3)%ansi(white)%format("&10.0n",@armhit)%ansi(bright,blue)"("%ansi(white)%eval(@armhit*100/@weaphits)"%"%ansi(bright,blue)")"%ansi(bright,blue)%format("&18s", "Legs:")%repeat(" ",3)%ansi(white)%format("&10.0n",@leghit)%ansi(bright,blue)"("%ansi(white)%eval(@leghit*100/@weaphits)"%"%ansi(bright,blue)")"}
#echo {%repeat(" ",2)%ansi(bright,blue)%format("&5s", "Tail:")%repeat(" ",3)%ansi(white)%format("&10.0n",@tailhit)%ansi(bright,blue)"("%ansi(white)%eval(@tailhit*100/@weaphits)"%"%ansi(bright,blue)")"%ansi(bright,blue)%format("&18s", "Wings:")%repeat(" ",3)%ansi(white)%format("&10.0n",@winghit)%ansi(bright,blue)"("%ansi(white)%eval(@winghit*100/@weaphits)"%"%ansi(bright,blue)")"}


Returns:
Code:

  Head:            2(16%)            Torso:           10(83%)
  Arms:            0(0%)             Legs:            0(0%)
  Tail:            0(0%)            Wings:            0(0%)


The percentages increasing in digit count pushes the right column over. Same old problem. 'Cept I tried the earlier solution and tried t apply it to this issue and I failed. :( I feel dumb, but I can't help it.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Fri May 27, 2011 2:25 am   
 
are you sure all the variables have a value that is not 0?
0*100/x=0

also, you might want to use 100.0 to force it to do float math instead of integer math
_________________
Discord: Shalimarwildcat
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri May 27, 2011 10:05 am   
 
The reason why it's giving off-alignment columns is because you're padding "Torso" in the front. The padding of spaces begins at the position of the last character, so as the first column grows larger, the further to the right the second column will be.

The way to fix this is not use %format("&18s", "Torso:"), but instead, use the format off the %eval.

Code:
%format("&-18s",%concat(%ansi(bright,blue),"(",%ansi(white),%eval(@headhit*100/@weaphits),"%",%ansi(bright,blue),")")


The - sign says 'Put the x amount of spaces behind me, accounting for my length first.' If you change them all to that, then you'll find the second column always lines up perfectly.
Reply with quote
Nethran
Novice


Joined: 25 Apr 2011
Posts: 32

PostPosted: Fri May 27, 2011 2:47 pm   
 
Woot. Took me a sec, but apparently I also wasn't spacing the percentages far enough from the values of the hit locations, so it wasn't allowing the formatting to work right. Trew in two extra spacs to allow for up to 100% and it's working perfect again. :) Thanks again, guys.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net