Help with statusbar label

Post Reply
Kalyth
Posts: 5
Joined: Sat Apr 27, 2013 1:48 am

Help with statusbar label

Post by Kalyth »

I'm attempting to migrate from zmud to mudlet and so I'm pretty new to mudlet.
I am trying to create a status bar that sits on the bottom of my screen and displays text according to triggers that fire. That part is simple enough and I have it working, but the problem comes when I'm trying to color the text according to the trigger.

Is there an easy way to do something like, label.cecho("<red>This is red text" .. " " .. "<blue>And this is blue text")? I found that when trying to do that the stylesheet I created for the label overrides the colors and it just sets it all to the color in the stylesheet. I also tried to use html formatting but I could not figure out a way to concat the tags so that I could throw in a variable as the text to display.

Thanks and sorry if I'm not coming across clearly.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Help with statusbar label

Post by Jor'Mox »

Ugly, but it gets the job done.
Code: [show] | [select all] lua
echo(label_name, [[<font color="color_name">]] .. text .. [[</font>]])

Kalyth
Posts: 5
Joined: Sat Apr 27, 2013 1:48 am

Re: Help with statusbar label

Post by Kalyth »

Thanks, while not exactly what I was hoping for, that did show me how to concat tags together to use variables. I might be able to get this working now.

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Help with statusbar label

Post by Jor'Mox »

You did try this first, right?
Code: [show] | [select all] lua
cecho(label_name, "plain text <red> red text <blue> blue text <reset> more plain text")
And that is what wasn't working?

Kalyth
Posts: 5
Joined: Sat Apr 27, 2013 1:48 am

Re: Help with statusbar label

Post by Kalyth »

yea that doens't work, only displays "more plain text" and it comes out red (the color set by the stylesheet)

Jor'Mox
Posts: 1146
Joined: Wed Apr 03, 2013 2:19 am

Re: Help with statusbar label

Post by Jor'Mox »

Yeah, I have had issues with getting the text in labels to be the color I want it to be. Hence why I had to resort to what I posted above. You can also use <b></b>, <center></center>, and other html tags to make it behave if it isn't doing what you want. Again, not ideal, but better than not making it work.

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Help with statusbar label

Post by demonnic »

cecho() is primarily for consoles, whether it be the main console or a miniconsole. Cecho is itself a wrapper to avoid everyone having to use the fg(), bg(), etc functions themselves with rgb values every time they want to color something. hecho and decho are the same, but using hex and decimal values rather than color names.

Labels on the other hand are pretty much straight up QLabels from Qt, iirc, and so you give up some of the convenience functions (cecho, etc) in order to gain the ability to use html and css in your gui element.

Granted, this is from my use of it, I'm not the actual developer. That being said, you can use miniconsoles layered overtop of labels and vice versa to achieve some rather nice effects.

Are you using the bare metal GUI functions, or one of the two major frameworks for working with GUIs, Geyser or Vyzor? While there is nothing wrong with using the bare bones functions, both of these frameworks have abstracted out a fair bit of the more tedious work, while still leaving you with the ability to run bare bones functions against them (in Geyser, at least... I haven't used Vyzor much myself, but hopefully someone with more Vyzor experience will chime in). I recommend looking at one of them, especially when you're new to Mudlet for a couple off reasons.

1.) They make creating your GUI much, much easier. They handle resizing, do the math for you for converting # characters at X font size with Y font into pixel sizes, etc. All of the fiddling which one would normally have to handle themselves is wrapped up and tucked out of site.
2.) There is, like anything else, a startup cost with learning a new MUD client.It's a new interface, a new scripting language (sometimes), in some cases an entirely new way to think of triggers and the like. Mudlet involves some new trigger concepts, often a new language, but even if not an entirely new API from the one they're used to. Even using the frameworks for GUI creation the UI elements aren't really the same as in other clients. Decreasing this initial cost of entry to making Mudlet look the way you want, while simultaneously learning the skills which will help you get it to behave the way you want as well, is really in your best interest. Then if you feel the need to (some do) you can go digging into the way it is doing things behind the scenes.

Just my $0.02.

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Help with statusbar label

Post by Akaya »

If you're looking to use the Vyzor framework, here's a sample script of how your 'status bar' can be created.

This version uses a label (also called a Frame in Vyzor). You pre-define the text color. Useful if everything in your status bar is the same color.
You can display text in a label via Status_Bar:Echo("my text")
Code: [show] | [select all] lua
Status_Bar = Vyzor.Frame("Status_Bar", .7, .9, .3, .1)
This version uses a miniConsole. You set the color of the text when you echo to the status bar.
You can display colored text in a miniConsole via cecho() like so:
Status_Bar:CEcho("<yellow>my text")
Code: [show] | [select all] lua
Status_Bar = Vyzor.MiniConsole("Status_Bar", .7, .9, .3, .1)
Keep in mind these scripts require that you have Vyzor installed on your profile. The latest copy can be found here

Kalyth
Posts: 5
Joined: Sat Apr 27, 2013 1:48 am

Re: Help with statusbar label

Post by Kalyth »

Thanks everyone for the replies. I suppose the real question I should have asked was is there a way to parse a line of text from the mud and capture the colors from it so that you can apply those colors to a label? I thought about trying to write my own function that would take a selection and parse through it and read in the color of each character. That way I could apply it to a label or do some other things to it but I just don't see a way to go about doing that. Is something like that possible?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Help with statusbar label

Post by Vadi »

Yep, that is possible - use selectString() to select your character and getFgColor() & getBgColor() to find out its colour.

Post Reply