Page 29 of 33

Re: Vyzor, UI Manager for Mudlet

Posted: Tue Jan 21, 2014 10:46 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Tue Jan 21, 2014 11:23 pm
by Akaya
Code: [show] | [select all] lua
myGauge:Echo([[<span style = "color: white">my text</span>]])

Re: Vyzor, UI Manager for Mudlet

Posted: Sun Jan 26, 2014 10:45 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Sun Jan 26, 2014 10:57 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Mon Jan 27, 2014 9:32 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Mon Jan 27, 2014 9:42 pm
by Akaya
use tags. <center> </center>
Code: [show] | [select all] lua
mylabel:echo([[<center><span style="color: white">my text</span></center>]])

Re: Vyzor, UI Manager for Mudlet

Posted: Tue Jan 28, 2014 12:34 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Tue Jan 28, 2014 3:23 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Tue Jan 28, 2014 6:35 pm
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.

Re: Vyzor, UI Manager for Mudlet

Posted: Tue Jan 28, 2014 6:56 pm
by Oneymus
No problem. Happy to help!