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
optimus101
Newbie


Joined: 12 May 2002
Posts: 0
Location: USA

PostPosted: Fri Apr 12, 2002 5:11 pm   

Advanced Trigger/Variable Question
 
Is there a way to force a variable to remain a certian number of digits, even if the first digit(s) are 0? I'm setting up a trigger to count down time left on spells based on initial text received from the mud, and display the countdown in the status window (as 3-digit numbers)

But I have 2 columns in the status window, and if one of the spells in the first column drops below 3 digits, it messes up the alignment in the second column.

Basically I'm looking for a way to force the variable to stay as 3 digits like:

101
100
099
098

I'm using an #ALARM'd #IF command currently to tick it down every 2 seconds.

#TRIGGER {(%w)(*): yes(*)(%w) time(*): (%d)} {#VARIABLE v%1TIME %6;#ALARM {-*:*2} {#IF (@v%1TIME > 0} {#ADD v%1TIME -1} {#VAR v%1TIME ---;#UNTRIGGER {-*:*2} {v%1CLASS})}} [v%1CLASS]

Alternatively, if someone knows how to make the status window 'think' there were 3 digits there, even if there was only 2 or 1, that would work as well.

Here's a sample of my status window:

%ansi( bold, green)CLAWS_______: %if( @vCLAWS="YES", %ansi( bold, green)YES, %ansi( bold, red) NO) %ansi( bold, yellow)@vCLAWSTIME %ansi( bold, green)DISEASE____: %if( @vDISEASE="YES", %ansi( bold, green)YES, %ansi( bold, red) NO) %ansi( bold, yellow)@vDISEASETIME

The "vCLAWS" and "vDISEASE" variables are set by a seperate trigger off the spell being cast/fading. The times are set using the script above.

Any help is greatly appreciated. ;)

-Brak
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Apr 12, 2002 8:01 pm   
 
%format
I don't think you can get leading zeros with it, but it will give leading spaces which will preserve your alignment.
%format("&3.0f",@vCLAWSTIME)

LightBulb
Vague questions get vague answers
Reply with quote
optimus101
Newbie


Joined: 12 May 2002
Posts: 0
Location: USA

PostPosted: Fri Apr 12, 2002 10:09 pm   
 
COol, that works, I found an alternate way to do it by nesting like 6 if statements inside each other, but %format is a lot neater. ;) Thanks.

-Brak
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Apr 12, 2002 11:03 pm   
 
quote:

COol, that works, I found an alternate way to do it by nesting like 6 if statements inside each other, but %format is a lot neater. ;) Thanks.

-Brak



If you want to add leading zeros, you can simply use something like this:

#alias Pad {#loop 1,%eval(@stringlength - %len(@%1)) {#variable TempVar %concat("0",@TempVar)}
#variable %1 %concat(@TempVar,"@%1)
#unvar TempVar
}

li'l shmoe of Dragon's Gate MUD
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