Geyser gauges help

Post Reply
Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Geyser gauges help

Post by Silvine »

Hi i'm trying to add a few vertical gauges but cant find any code examples to send me on my way. Can anyone point me in the right direction of how to set them up.

thanks

Silv

Sheia
Posts: 33
Joined: Tue Dec 01, 2009 4:40 am

Re: Geyser gauges help

Post by Sheia »

I don't use Geyser yet, but I think you want something like the following:
Code: [show] | [select all] lua
geyserGauge = Geyser.Gauge:new({
      x = "0px", y = "0px",
      width = "200px", height = "20px",
      orientation = "vertical"})
The width and height of the gauge actually makes the gauge vertical, orientation has the gauge fill and empty vertically. Naturally the x and y allow you to decide where you want the gauge to be displayed.

Take a look at Geyser Docs and download GeyserOverview.pdf and GeyserDoc.zip. GeyserDoc explains the various attributes(right word to use?) you can change with Geyser. I'm new to all this myself, but I hope it helps!

Silvine
Posts: 142
Joined: Sat Oct 23, 2010 2:36 pm

Re: Geyser gauges help

Post by Silvine »

Thanks, the documentation proved useful. I worked out a solution, its probably a bit confused but it works nicely for me so i thought other beginners might find it useful.
Code: [show] | [select all] lua
-- First make a container to put your guages and Hbox in. I used Hbox because I didnt really like how text displays in the gauge so added a Hbox to dump the text in.

Gcontainer = Geyser.Container:new({
	name="Gcontainer",
	x=50, y=50,
	width=90, height=250,
})

-- Then make the Hbox, its really nice cause it just divided itself up equally so no thought required

StatsBox = Geyser.HBox:new({
	name="StatsBox",
	x=0, y=0,
	width=90, height=50,
})


Gcontainer:add(StatsBox) -- Add the box to the container
StatsBox:move(0,200) -- and move it to the bottom below where the gauges will go

-- Create and add the Labels to the Hbox

StatsBoxHealthLabel = Geyser.Label:new({
	name="StatsBoxHealthLabel",
	format = "cbi", -- centre, bold, italics
},
StatsBox)

StatsBoxHealthLabel:setColor(100,10,10) -- red, green, blue


StatsBoxManaLabel = Geyser.Label:new({
	name="StatsBoxManaLabel",
	format = "cbi",
},
StatsBox)

StatsBoxManaLabel:setColor(10,100,10)


StatsBoxMovLabel = Geyser.Label:new({
	name="StatsBoxMovLabel",
	format = "cbi"
},
StatsBox)

StatsBoxMovLabel:setColor(10,10,100)

-- Now make the gauges

GGaugeHealth = Geyser.Gauge:new({
    x=0, y=0,
    width =30, height =200,
    orientation = "vertical",
	name = "GGaugeHealth",
	format = "cbi",
})


GGaugemana = Geyser.Gauge:new({
    x=30, y=0,
    width =30, height =200,
    orientation = "vertical",
	name = "GGaugemana",
	format = "cbi"
})


GGaugemov = Geyser.Gauge:new({
    x=60, y=0,
    width =30, height =200,
    orientation = "vertical",
	name = "GGaugemov",
	format = "cbi"
})

-- Add them to the container

Gcontainer:add(GGaugeHealth)
Gcontainer:add(GGaugemana)
Gcontainer:add(GGaugemov)

-- Move the whole lot to where i wanted it. WindowHeight is a variable that contains the height off my main window

Gcontainer:move(660-90,WindowHeight-300)

-- Set the gauge colours (red, green, blue)

GGaugeHealth:setColor(150, 10, 10)
GGaugemana:setColor(10, 150, 10)
GGaugemov:setColor(10, 10, 150)

-- give the gauges some values, these are obtained from a trigger on the prompt
-- c is current health, mana, move
-- m is max health, mana, move
-- nil is no text on the gauge
-- it works out the maths for you, very handy

GGaugeHealth:setValue(chealth, mhealth,nil)
GGaugemana:setValue(cmana, mmana,nil)
GGaugemov:setValue(cmov, mmov,nil)

-- put the text in the Hbox labels, it understands HTML tags as well

StatsBoxHealthLabel:echo([[<font color="light_goldenrod"></font>]]..chealth..[[<br><br>]]..mhealth..[[<br>]].."HP")
StatsBoxManaLabel:echo([[<font color="light_goldenrod"></font>]]..cmana..[[<br><br>]]..mmana..[[<br>]].."MAN")
StatsBoxMovLabel:echo([[<font color="light_goldenrod"></font>]]..cmov..[[<br><br>]]..mmov..[[<br>]].."MOV")
Simple as that.

Post Reply