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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Wed May 13, 2009 2:56 am   

Scripts in Buttons
 
I have a variable that stores my mapgraphic, and as of now I output it in a window that floats, but with the new floating buttons, this can be obsolete. However, you can't use %ansi, %if, %cr, ect. in buttons. Is there a way to have the button evaluate these sequences so I can have a variable like:

Quote:

" |/ "| O- |" |X| "| O-O- |" |X|X|X|/ "| @-O-O-O- | 


And just paste the variable into the button where it would get the coloring the mud provides and its spacing. Other instances where I wished I coudl do this is to color a variable in a button different colors if it is on or off, atm I switch between different buttons with different colors with #t- buttonoff #T+ buttonon, ect. But this can be reduced to 1 button if I could use %if(@apowerison=1,%ansi(red)@variable,%ansi(cyan)@variable).
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed May 13, 2009 1:15 pm   
 
You shouldn't be using escape sequences in scripts. Use %e if you need the escape sequence for something, but you almost certainly don't need it.

You never said whether you're using the caption of the button or something else. Functions (any functions, including %if and %ansi and %cr) work just fine in button captions, so if you meant captions, you're doing something else wrong. If you didn't mean captions, what did you mean?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Wed May 13, 2009 8:05 pm   
 
I meant captions. Currently in my script as I do use it, the output from the mud is captured with the escape sequences so I can use #say and preserve the ansi/line breaks/ect without any work on my part. The escape sequences are used to maintain the color that the graphical map has for mobs/players/ect. And I've tried to use %if in the button captions unsuccessfully with something like %if(@bstatus=1,%ansi(red)@br,%ansi(blue)@br). The button shows %if(@b.... ect. So yeah looks like I'm doing something else wrong.
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Wed May 13, 2009 10:57 pm   
 
%if does work in a button, i am corrected, but my true/false values were what was resulting in my captions being code. %ansi does not work in a button's caption.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed May 13, 2009 11:17 pm   
 
No, there is no way to support multi-color button captions, sorry. The %crlf should work for line breaks to get multiline buttons. But you can only have a single text color and single background color for a button. Other functions like %if should work fine. It's just the functions that try to change colors that won't work.
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Thu May 14, 2009 1:01 am   
 
Ok, well the new buttons are perfect for placing your hp bar seamlessly on your screen. So when you are trying to make those buttons containing your hpbar/other information informative of various states (such as low hp/mana/ect) obviously you want colors. So yeah, it is possible to make a button into many different buttons and turn off one "low hp" button and turn on the "normal hp" button. However this is messy and annoying for many settings. I have no idea how difficult it would be to have the captions respect %ansi or other such color changes, but if it is not too trivial I think it would be a great idea
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu May 14, 2009 1:06 am   
 
Why not just use a gauge-type button for your various-state info? For more complex things you can use a multistate button whose state is controlled by a variable - changing the variable should change the displayed state.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Thu May 14, 2009 1:57 am   
 
The hp and those instances are secondary and just something I thought would be a common mud example to use on the forums, and I hate gauges so I would represent them with numbers. What brought my attention to this was using various guild powers and marking they are enabled or not. If a power is enabled I like to color the remaining number of power uses red. So it is more of a toggle issue that brought this to my attention. Currently if a power is on, that triggers one button to turned off and that is replaced with another which uses a different text color but otherwise is indistinguishable from the first. Gauges are useless when you have powers with 5/6 uses left and you want to indicate with a color whether that power is enabled. Sure, there are a million ways to do this but it's the more intuitive and simplest way to show it. I have 5 uses of dodge left, is my dodge on? it's red so it must be, ect.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu May 14, 2009 5:14 pm   
 
That's what the Status Bar is for, since the status bar supports multiple colors. Multiple status bars will be added soon. But as I said, there is no way for me to support multiple colors in a button caption...the button component that I'm using just doesn't allow anything like that, sorry. Perhaps in the future I'll add a new "button type" that displays a color panel (like the status bar) instead of a real button. You wouldn't be able to click on it like a button or anything like that, but it might be useful for floating status info like you mentioned. Not sure how hard it would be, but it's probably not something I'll be able to do for the current beta cycle.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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