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
MyMiasma
Wanderer


Joined: 26 Oct 2012
Posts: 56

PostPosted: Sat Dec 06, 2014 1:32 am   

%btncol
 
I have been trying and failing to get my button color to change properly.

I can draw 3 "runes" on my sword. I have made 3 buttons, one for each rune.

Each button is a 'gauge' that displays the runecaption(name of the rune) and either a
'1' or a '0'(1 if the rune is currently on the sword, or '0' if it has faded.

I would like to have my button turn red if @runetype is 0
and turn green if @runetype is 1

Currently
Here is the script:

#CLASS {lily} {disable|setdef}
#VAR darknessrune {1} {0}
#VAR darkmagicrune {0} {0}
#VAR nothingnessrune {1} {0}
#TRIGGER {Its hue darkens, until it is as black as your soul.} {#var darknessrune 1}
#TRIGGER {} {}
#TRIGGER {Your blade slowly loses its dark hue, and goes back to normal.} {#var darknessrune 0}
#TRIGGER {The dark magic is one with it, now.} {#var darkmagicrune 1}
#TRIGGER {The rune of dark magic fades, your blade is normal once more.} {#var darkmagicrune 0}
#TRIGGER {and is one with the blade.} {#var nothingnessrune 1}
#TRIGGER {away into itself.} {#var nothingnessrune 0}
#TRIGGER {You cancel the effect of the rune of razor darkness.} {#var darknessrune 0}
#TRIGGER {You cancel the effect of the rune of dark magic.} {#var darkmagicrune 0}
#TRIGGER {You cancel the effect of the rune of nothingness.} {#var nothingnessrune 0}
#BUTTON 14 {DM: @darkmagicrune} {#IF (@darkmagicrune = 0) {%buttoncol( 14, red)} {%buttoncol( 14, green)}} {} {} {@darkmagicrune} {} {} {} {} {} {} {} {} {} {} {Gauge||12|1|0|7} {} "" {Explore|Inset} {} {}
#BUTTON 15 {RD: @darknessrune} {} {} {} {} {} {} {} {} {} {} {} {} {32} {} {Gauge||12|||7} {} "" {Explore|Inset} {} {}
#BUTTON 16 {N: @nothingnessrune} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {Gauge||12|||7} {} "" {Explore|Inset} {} {}
#CLASS 0

//My problem lies somewhere at #button 14, what am I doing wrong?
_________________
It is better to die on your feet than to live on your knees.
Reply with quote
Thrillhouse8
Beginner


Joined: 21 Sep 2004
Posts: 18

PostPosted: Mon Dec 22, 2014 2:31 pm   
 
As a disclaimer, I've not worked with zScript in ages, so I'll just refer you to the documentation. If I remember correctly, hashes(#) prefix commands, while the % prefix are used as functions evaluated within commands.
From , the %btncol function help:
Quote:
Examples:

#BUTTON 1 "Test button" {button clicked}
#CALL %btncol(1,blue,green)
Set the button color to blue text on green background.


You could set a trigger to fire on those lines, changing the button color each time a value changes, but I would assume the following would be faster, changing the aspect of button behavior directly within the button setup. I've bolded the relevent arguments:

Code:
#BUTTON id|number Off-caption On-command On-caption Off-command Value-expression [b]Variable-name [/b]Bitmap-filename AutoSize Width Height AutoPos Top Left [b]Off-color On-color[/b] [i]Button-Kind[/i] Bitmap-margin [i]Classname Options [/i]ToolTip ID PanelNum


By setting the Variable-name, the button will track said variable, switching state automatically when the variable changes. Settings should then be:

Code:
#BUTTON 14 {} {} {} {} {} {DM: @darkmagicrune} {[b]@darkmagicrune[/b]} {} {} {} {} {} {%color(red)} {%color(green)} {Gauge||12|||7} {} "lily" {Explore|Inset} {} {}
#BUTTON 15 {} {} {} {} {} {RD: @darknessrune} {[b]@darknessrune[/b]} {} {} {} {} {} {%color(red)} {%color(green)} {Gauge||12|||7} {} "lily" {Explore|Inset} {} {}
#BUTTON 16 {} {} {} {} {} {N: @nothingnessrune} {[b]@nothingnessrune[/b]} {} {} {} {} {} {%color(red)} {%color(green)} {Gauge||12|||7} {} "lily" {Explore|Inset} {} {} 


I've not verified these work, but you should have a bit more to work from if they don't.
*EDIT: removed brackets
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Thu Dec 25, 2014 2:05 am   
 
%buttoncol is something that you #CALL to change the color of an existing button.
It is not used within the button itself (usually)
Buttons in general are easier to work with in the GUI, because the command has just so many options.

Using the #BUTTON command to redefine the button entirely is likely going to be slower than calling a function to change just one aspect of it.
_________________
Discord: Shalimarwildcat
Reply with quote
MyMiasma
Wanderer


Joined: 26 Oct 2012
Posts: 56

PostPosted: Fri Dec 26, 2014 7:33 am   
 
Thank you both, I attempt to get it working tomorrow.
Merry xmas!
_________________
It is better to die on your feet than to live on your knees.
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