Vyzor, UI Manager for Mudlet

Share your scripts and packages with other Mudlet users.
User avatar
Calixa
Posts: 25
Joined: Sat Nov 20, 2010 5:51 pm
Location: Lusternia

Re: Vyzor, UI Manager for Mudlet

Post by Calixa »

How do you set the font color of a gauge? I'd like the text on them to be white, as my gauges have a black background.

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

Re: Vyzor, UI Manager for Mudlet

Post by Akaya »

Code: [show] | [select all] lua
myGauge:Echo([[<span style = "color: white">my text</span>]])

User avatar
Calixa
Posts: 25
Joined: Sat Nov 20, 2010 5:51 pm
Location: Lusternia

Re: Vyzor, UI Manager for Mudlet

Post by Calixa »

Thank you. How would I go about replacing 'my text' with the current and max hp of my character? I'd like to grab this from gmcp.Char.Vitals.

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

Re: Vyzor, UI Manager for Mudlet

Post by Akaya »

Code: [show] | [select all] lua
myGauge:Echo([[<span style = "color: white">]]..gmcp.Char.Vitals.hp..[[/]]..gmcp.Char.Vitals.hpmax..[[</span>]])
I think that's the variable for maximum health. Might be maxhp though.

User avatar
Calixa
Posts: 25
Joined: Sat Nov 20, 2010 5:51 pm
Location: Lusternia

Re: Vyzor, UI Manager for Mudlet

Post by Calixa »

Sorry to keep pestering with questions. Here's a code sample first to show what I have. I have consulted the documentation and made some educated guessed, but no luck yet fully getting what I want.
Code: [show] | [select all] lua
local back_bg = Vyzor.Background(Vyzor.Brush(Vyzor.Color(Vyzor.ColorMode.Name, "black", 0, 0)))
local front_bg_hp = Vyzor.Background(Vyzor.Brush(Vyzor.Color(Vyzor.ColorMode.Name, "firebrick", 0, 0)))

local gauge_back_hp = Vyzor.Frame("back hp", .295, .010, .34, .025)
gauge_back_hp:Add(back_bg)
local gauge_front_hp = Vyzor.Frame("front hp")
gauge_front_hp:Add(front_bg_hp)

local gauge_hp = Vyzor.Gauge("gauge hp", "gmcp.Char.Vitals.hp", "gmcp.Char.Vitals.maxhp", gauge_back_hp, gauge_front_hp)
gauge_hp:Echo([[<span style = "color: white; text-align: center;">]] .. gmcp.Char.Vitals.hp .. [[ / ]] .. gmcp.Char.Vitals.maxhp .. [[</span>]])
Vyzor.Left:Add(gauge_hp)	
Two problems here: First off, the text colours white but it does not center. Is text-align not supported? If so, how could I get it to center the text? Secondly, when recieving gmcp data, the text suddenly changes back to black, does become centered, and displays hp / maxhp. Nice, but not quite what I wanted. What I want to achieve is centered white text that gets its data from gmcp. I'm almost certain this means the Vyzor.Gauge function needs some editing, but the text values there seem required.

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

Re: Vyzor, UI Manager for Mudlet

Post by Akaya »

use tags. <center> </center>
Code: [show] | [select all] lua
mylabel:echo([[<center><span style="color: white">my text</span></center>]])
Last edited by Akaya on Tue Jan 28, 2014 5:38 pm, edited 1 time in total.

User avatar
Calixa
Posts: 25
Joined: Sat Nov 20, 2010 5:51 pm
Location: Lusternia

Re: Vyzor, UI Manager for Mudlet

Post by Calixa »

Ah yes, forgot those exist. What about the overwriting? I'm guessing it is due to the line that defines the gauge, but the text parameters seem mandatory.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet

Post by Oneymus »

Gauges have a TextFormat property you can use to change the text. By default, the format is "<center>%s / %s</center>". The two variables (%s) in there correspond to the current and maximum values set when you make a new gauge.

There is also the AutoEcho property, which defaults to true.

This means, every time a gauge updates, it will automatically echo "<center>10 / 100</center>", for example.

One solution to your problem is to set AutoEcho to false, and manually echo every time you call gauge:Update(). Or, and this is the preferred method, you can just set TextFormat to whatever you want, and Vyzor will automatically echo that every Update.

For instance:
Code: [show] | [select all] lua
myGauge.TextFormat = [[<center><span style="color: white">%s / %s</span></center>]]
If you haven't turned AutoEcho off, and you're manually echoing, then you're echoing twice. Which might explain any oddities, like the overwriting.

User avatar
Calixa
Posts: 25
Joined: Sat Nov 20, 2010 5:51 pm
Location: Lusternia

Re: Vyzor, UI Manager for Mudlet

Post by Calixa »

Awesome, that got it working the way I want. Thank you both for your help :) Got to say, you can do some pretty nifty stuff with Vyzor, certainly going to tinker with it some more.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet

Post by Oneymus »

No problem. Happy to help!

Post Reply