TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Fixed width for variable display

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
oneor11



Joined: 01 May 2017
Posts: 10

PostPosted: Wed May 03, 2017 10:52 pm    Post subject: Fixed width for variable display Reply with quote

Hello. On a split line I have an hpbar. For simplicity, let's say it looks like this:

HP: 1000/1000 SP: 500/500

The hp and sp are variables captured from the screen. That's working well, but the hpbar is jittery when the HPs and/or SPs fall below 1000 since it's losing 1 character length. So I would like to 'reserve' 4 spaces for the display of the number so that it will take up 4 spaces if the number is 1000 or 10. FOr example (brackets included to aid in visualization. Dots represent spaces for visualization only since the forum strips the space padding away):

HP: [1000]/1000
HP: [.900]/1000
HP: [..90]/1000
HP: [...9]/1000



I suspect the #FORMAT is the answer and perhaps the %+s, but I can't figure out how to build an easy statement. I suspect the "%+4s" will need to be dynamic in that I will need to read the length of the string and subtract it from 4. So if the HP is 1000 the argument is %+0s, but if the HP is 9 it is %+3s. I'm not sure. I would appreciate your help with the syntax and alogirthm.
Back to top
View user's profile Send private message
oneor11



Joined: 01 May 2017
Posts: 10

PostPosted: Wed May 03, 2017 11:01 pm    Post subject: Reply with quote

For more clarity, here is how I would like 900 displayed.

Code:

#VAR test 900;
#FORMAT test {[%+1s$test]}


#OK. VARIABLE {test} HAS BEEN SET TO {[ 900]}.

But I can't figure out a way to generate that "%+Xs" dynamically.
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Thu May 04, 2017 7:14 am    Post subject: Reply with quote

Maybe you are just using format in the wrong way, look at this example if it's what you want to obtain

Code:

#var test {1000};#format {test} {[%+4s]} {$test}
#OK. VARIABLE {test} HAS BEEN SET TO {1000}.
#OK. VARIABLE {test} HAS BEEN SET TO {[1000]}.

#var test {500};#format {test} {[%+4s]} {$test}
#OK. VARIABLE {test} HAS BEEN SET TO {500}.
#OK. VARIABLE {test} HAS BEEN SET TO {[ 500]}.

#var test {1};#format {test} {[%+4s]} {$test}
#OK. VARIABLE {test} HAS BEEN SET TO {1}.
#OK. VARIABLE {test} HAS BEEN SET TO {[   1]}.
Back to top
View user's profile Send private message
oneor11



Joined: 01 May 2017
Posts: 10

PostPosted: Thu May 04, 2017 8:57 am    Post subject: Reply with quote

Thanks again for the help Powergod. This works beautifully. I appreciate your time and help.

Is there an area that I can go to that has more examples for all of these formats and commands? The manual is nice, and the scripts area helps a bit, but it seems the amount of solid examples of syntax and usage is missing.
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Thu May 04, 2017 12:16 pm    Post subject: Reply with quote

Mostly you'll have to random search on this forum, because somehow every area is covered here, the bad part is to actually find the right keywords to use... sometimes the best tricks appears in threads that have nothing to do with them...

The rest is to just try things in different ways until them works...

There was some cool unofficial documentation in the "links" section but seems dead by now...
I remember that it had a very good explanation+examples about how to use variables/arrays (because at the beginning I was pretty lost on the argument).

I still like how I'm constantly learning new things even after years of practice
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group