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

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: 412
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet

Post by Akaya » Tue Jan 21, 2014 11:23 pm

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

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: 412
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet

Post by Akaya » Sun Jan 26, 2014 10:57 pm

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

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: 412
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet

Post by Akaya » Mon Jan 27, 2014 9:42 pm

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

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

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

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 » Tue Jan 28, 2014 6:56 pm

No problem. Happy to help!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests