Register to post in forums, or Log in to your existing account

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion

Joined: 19 Jul 2007
Posts: 18

PostPosted: Sun Jan 03, 2010 2:59 pm   

use of %if and %ansi on button captions
I searched the forums and only found a couple posts that came close to this, but tricks listed in them did not help. I'm hoping this is just a simple formatting issue.

CMUD 3.12

I added a button to simply display my character's current alignment. I have a variable that captures the alignment from my prompt, then I used the variable in the button caption so that it updates. That part works just fine.

Caption= Align: @align

However, I wanted to spice it up a bit, by having the color of the displayed variable change at certain values, but it only seems to partially work.

Caption= Align: %if(@align > 500, %ansi(blue), @align)

The %if statement appears to work, as when my align is under 500, it displays the value correctly in the default black. But when my align is >500, and should display in blue, it displays scrambled garbly-gook on the button. I've tried using just 1 color, spaces after the "," and w/o, but every time it appears to need force the %ansi color, it seems to throw up garbage.

Is this a known issue, or am I just using improper syntax? I had similar functionality in zmud, but even there, getting colors, etc to work on the button labels was trickier than just writing it in a script to echo out to the main screen.
Reply with quote

Joined: 17 Apr 2005
Posts: 496

PostPosted: Sun Jan 03, 2010 4:37 pm   
I don't think ANSI colours work on buttons at all. This has nothing to do with %if. It's just that button colours are controlled in a different manner (using the button colours options on the options tab in the settings editor). I don't know of an easy way to change the button text colour like that. You might consider switching to a gauge type button and changing the background colour instead.

I also think changing the text colour would be a good feature for gauge-type buttons since currently it is simple to change the button background colour, but you're limited to colours which look good with the text colour (for example, you can't go from light to dark or back again, because your text will be unreadable). The gauge type buttons should have all three colour options (background, text, outline) changeable when it hits the "low" level.
Reply with quote

Joined: 23 Nov 2004
Posts: 364

PostPosted: Sun Jan 03, 2010 7:53 pm   
I asked for this feature a while back, and I forget zugg's answer but basically it would be a lot more work than at first glance. To do this for me, I have 2 buttons with different color types, and upon a power activating/deactivating I just enable/disable the buttons
Reply with quote

Joined: 19 Jul 2007
Posts: 18

PostPosted: Sun Jan 03, 2010 9:07 pm   
Thats a shame.. would be a really cool feature to simply process the existing code on the button label. In comparing with my zmud.. my previous color codes were done to the status bar and not via buttons.

I suppose for the time being, I could simply add this to my status bar.

Thanks for the replies.
Reply with quote

Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Jan 10, 2010 6:24 am   
Since nobody suggested an alternative I thought I would whip up something for you.

Highlight the text in the code box and paste it into the settings editor to try it out.

<?xml version="1.0" encoding="ISO-8859-1" ?>
  <button name="bcolorb" autosize="false" width="94" height="19" toolbar="2" color="yellow" textcolor="cornflowerblue" priority="11590" copy="yes">
    <caption>Align: @bcolor</caption>
    <value>#call @bcolor(%case(%random(1,4), "good", "bad","diabolic", "saraphic"))</value>
  <alias name="aset" copy="yes">
    <value>#switch ($align > 750) {#call @bcolor("saraphic")} ($align > 500) {#call @bcolor("good")} ($align > 250) {#call @bcolor("bad")} ($align < 250) {#call @bcolor("diabolic")}</value>
  <var name="bcolor" copy="yes">saraphic</var>
  <func name="bcolor" copy="yes">
#switch @bcolor "good" {#call %btncol( bcolorb, "green", "blue")} "bad" {#call %btncol( bcolorb, "darkred", "black")} "saraphic" {#call %btncol( bcolorb, "cornflowerblue", "yellow")} "diabolic" {#call %btncol( bcolorb, "black", "mxpred")}</value>

If you click on the button that it creates it will change the text and the color of button.

It also creates an alias named aset that you can play with to change run the alignment using numbers.

Type aset 100 and you will be diabolical. etc
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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