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


Joined: 09 Oct 2008
Posts: 7

PostPosted: Mon Nov 02, 2009 10:11 am   

#IF statements
 
I'm trying to make a crude display showing active prots on my char using zmud 7.21.

This is what I have so far:

Name:
Prots

Value:
#echo ---------- Prots ----------
#IF @rage=1 {#echo | Rage is UP |}
#IF @rage=0 {#echo | Rage is DOWN |}
#IF @AC=1 {#echo | AC is UP |}
#IF @AC=0 {#echo | AC is DOWN |}
#echo ---------------------------

For some reason it won't add those extra spaces after the UP and DOWN messages, leaving just one space before the |.

What I would also like is to colour the prots which are UP to blue and those that are DOWN in red. Also a yellow border and bold green title (Prots).

Any suggestions welcome

Thanks in advance.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Nov 02, 2009 2:50 pm   
 
Quote the echos. Instead of:

#ECHO | Rage is UP |

do:

#ECHO "| Rage is UP |"

This is true for any and all strings. Single spaces usually get by, but multiple spaces will always need quotes.

Charneus
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Nov 02, 2009 2:50 pm   
 
As for color, just put it like so:

#ECHO "| Rage is "%ansi(yellow)"UP "(reset)"|"

Or whatever colors you want.

Charneus
Reply with quote
TimTam
Newbie


Joined: 09 Oct 2008
Posts: 7

PostPosted: Tue Nov 03, 2009 7:09 am   
 
OK thanks!

You put quite a few quotes in that, one for the whole string, one for the colour and one each around the reset. Is there a help file that shows the syntax?

Also, am I doing the IF statements in the most efficient manner? or should I use #else ?

Thanks
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Nov 03, 2009 1:09 pm   
 
The quotes are only around the string parts. Take a closer look and you'll see.

Also, there isn't an #ELSE command, but you can make it better by doing:

Code:
#ECHO "|     Rage is "%if(@rage, %ansi(blue)"UP",%ansi(red)"DOWN")".    |"


That, honestly, is the most effective way.

As far as documentation, it's not really documented anywhere except throughout the site. :p

Charneus
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Nov 03, 2009 2:30 pm   
 
To elaborate on the usage of %if(@rage, instead of %if(@rage=1, etc

If a variable has a value to it other than zero, it is considered true. Therefore, by asking if the variable has a value, it will return true or false.

The %if function syntax is simple.

%if(expression,then,else)

Charneus
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