|
SRPrice Beginner
Joined: 19 Jul 2007 Posts: 18
|
Posted: 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. |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: 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. |
|
|
|
chris-74269 Magician
Joined: 23 Nov 2004 Posts: 364
|
Posted: 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
|
|
|
|
SRPrice Beginner
Joined: 19 Jul 2007 Posts: 18
|
Posted: 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. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: 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.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<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>
</button>
<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>
<arglist>$align</arglist>
</alias>
<var name="bcolor" copy="yes">saraphic</var>
<func name="bcolor" copy="yes">
<value>bcolor=$alignment
#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>
<arglist>$alignment</arglist>
</func>
</cmud>
|
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 |
|
|
|
|
|
|
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
|
|