What am I doing wrong..?

Geyser is an object oriented framework for creating, updating and organizing GUI elements within Mudlet.
Post Reply
Saros
Posts: 9
Joined: Sat Oct 15, 2016 10:10 pm

What am I doing wrong..?

Post by Saros » Fri Oct 28, 2016 8:16 pm

First, I am totally new to Mudlet/LUA, so I am sure you'll get some laughs from my code.. :shock: ;) :lol:

Code: Select all

function createHpGauge(gname, xpx, ypx, gmessage)
	local gauge = Geyser.Gauge:new({name = gname, x = xpx .."px", y = ypx .."px", width = "80px", height = "15px",
										message = gmessage, fgColor = "white",},
  										leftBar)
	gauge.front:setStyleSheet([[
		background-color: RoyalBlue;
		padding: 1px;
	]])
	gauge.back:setStyleSheet([[
		background-color: gray;
	]])
	return gauge
end

function createManaGauge(gname, xpx, ypx, gmessage)
	local gauge = Geyser.Gauge:new({name = gname, x = xpx .."px", y = ypx .."px", width = "80px", height = "10px",
										message = gmessage, fgColor = "white",},
  										leftBar)
	gauge.front:setStyleSheet([[
		background-color: ForestGreen;
	]])
	gauge.back:setStyleSheet([[
		background-color: gray;
	]])
	return gauge
end

--function createLeftBar()
	leftBar = Geyser.Container:new({x=0,y=0,width="100px",height="100%",name="leftBar"})
	local xcord = 10
	local ycord = -50

	

	--hpgauges
	--Makena
	gaugeHpMakena = createHpGauge("gaugeHpMakena", xcord, ycord, "Makena")
	--Ahriman
	ycord = ycord-100
	gaugeHpAhriman = createHpGauge("gaugeHpAhriman", xcord, ycord, "Ahriman")
	--Fey
	ycord = ycord-100
	gaugeHpFey = createHpGauge("gaugeHpFey", xcord, ycord, "Fey")
	--Tyler
	ycord = ycord-100
	gaugeHpTyler = createHpGauge("gaugeHpTyler", xcord, ycord, "Tyler")
	--Saros
	ycord = ycord-100
	gaugeHpSaros = createHpGauge("gaugeHpSaros", xcord, ycord, "Saros")


	--managauges
	ycord = -33
	--Makena
	gaugeManaMakena = createManaGauge("gaugeManaMakena", xcord, ycord, "")
	--Ahriman
	ycord = ycord-100
	gaugeManaAhriman = createManaGauge("gaugeManaAhriman", xcord, ycord, "")
	--Fey
	ycord = ycord-100
	gaugeManaFey = createManaGauge("gaugeManaFey", xcord, ycord, "")
	--Tyler
	ycord = ycord-100
	gaugeManaTyler = createManaGauge("gaugeManaTyler", xcord, ycord, "")
	--Saros
	ycord = ycord-100
	gaugeManaSaros = createManaGauge("gaugeManaSaros", xcord, ycord, "")
That code creates the gauges as expected, but also results in this:

Image

This does not seem right, what am I doing wrong?

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

Re: What am I doing wrong..?

Post by Jor'Mox » Fri Oct 28, 2016 10:41 pm

Display it (meaning, put in this code somewhere at the end: display(gaugeManaTyler) ), and once we see what is in it, we may be better able to explain what is going on. Honestly though, I'm not super familiar with the variables tab in Mudlet...been working without it for so long, that I don't really know what to expect from it.

Saros
Posts: 9
Joined: Sat Oct 15, 2016 10:10 pm

Re: What am I doing wrong..?

Post by Saros » Fri Oct 28, 2016 11:00 pm

The output is crazy long... too long to display in my post

http://pastebin.com/raw/RUS8hwT2

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

Re: What am I doing wrong..?

Post by Jor'Mox » Fri Oct 28, 2016 11:05 pm

Looks like geyser going nuts. I tossed geyser a while back because it couldn't keep up with what I wanted to do. It was super slow when I had to resize me screen.

User avatar
SlySven
Posts: 927
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: What am I doing wrong..?

Post by SlySven » Sat Oct 29, 2016 3:19 pm

You've found a bit of, well, not exactly an, easter-egg but something sort of like that...

Lua has a single data type structure (a "table") and all the global stuff - global variables, global tables and, yes, functions are all stored in a master structure (the "_G" table) so when the Variable tab is opened it shows all of these. To be honest I'm not entirely sure why we show functions but I haven't yet done much in that area and I'm not the expert on it (I believe chris is the man behind it all). Anyhow the data for your shiny new gauge is stored as a table which the geysar "library" stores in that table you can see. There is an option to hide things in the display but the actions of that and the "save" option do not seem (to me) to be entirely intuitive when tables are involved... :?

BTW The Variable tab is not updated interactively it is a snapshot of what everything was when it was last redrawn - if a script/alias/etc. runs and adds/modifies/removes something in what is shown it does not show those changes unless you switch to a different tab and return to it. Although this can be irritating, it is done for performance reasons, as monitoring each item and redrawing everything if anything changes would slow things down... :geek:

Saros
Posts: 9
Joined: Sat Oct 15, 2016 10:10 pm

Re: What am I doing wrong..?

Post by Saros » Sat Oct 29, 2016 6:54 pm

Thanks for the background info SlySven, definitely helps to know whats going on!

I changed my code to below and everything works as "expected": The gauges are correctly created in the "hidden" geyser table, unlike before. Not sure why this works and the other code did not.

With the original code I posted, the gauge that was showing up in the variable tab (not a part of the hidden geyser table) was inaccessible, setValue() would fail, etc..
Code: [show] | [select all] lua
RoninMUDUI = RoninMUDUI or {}
RoninMUDUI.leftBar = RoninMUDUI.leftBar or Geyser.Container:new({x=0,y=0,width="100px",height="100%",name="leftBarName"})

--hpgauges
--Makena
RoninMUDUI.leftBar.gaugeHpMakena = RoninMUDUI.leftBar.gaugeHpMakena or Geyser.Gauge:new({name = "gaugeHpMakena", x = "10px", y = "-50px", width = "80px", height = "15px",
										message = "Makena", fgColor = "white",},RoninMUDUI.leftBar)
RoninMUDUI.leftBar.gaugeHpMakena.front:setStyleSheet([[
	background-color: RoyalBlue;
	padding: 1px;
]])
RoninMUDUI.leftBar.gaugeHpMakena.back:setStyleSheet([[
	background-color: gray;
]])

--Ahriman
RoninMUDUI.leftBar.gaugeHpAhriman = RoninMUDUI.leftBar.gaugeHpAhriman or Geyser.Gauge:new({name = "gaugeHpAhriman", x = "10px", y = "-150px", width = "80px", height = "15px",
										message = "Ahriman", fgColor = "white",},RoninMUDUI.leftBar)
RoninMUDUI.leftBar.gaugeHpAhriman.front:setStyleSheet([[
	background-color: RoyalBlue;
	padding: 1px;
]])
RoninMUDUI.leftBar.gaugeHpAhriman.back:setStyleSheet([[
	background-color: gray;
]])

--Fey
RoninMUDUI.leftBar.gaugeHpFey = RoninMUDUI.leftBar.gaugeHpFey or Geyser.Gauge:new({name = "gaugeHpFey", x = "10px", y = "-250px", width = "80px", height = "15px",
										message = "Fey", fgColor = "white",},RoninMUDUI.leftBar)
RoninMUDUI.leftBar.gaugeHpFey.front:setStyleSheet([[
	background-color: RoyalBlue;
	padding: 1px;
]])
RoninMUDUI.leftBar.gaugeHpFey.back:setStyleSheet([[
	background-color: gray;
]])

--Tyler
RoninMUDUI.leftBar.gaugeHpTyler = RoninMUDUI.leftBar.gaugeHpTyler or Geyser.Gauge:new({name = "gaugeHpTyler", x = "10px", y = "-350px", width = "80px", height = "15px",
										message = "Tyler", fgColor = "white",},RoninMUDUI.leftBar)
RoninMUDUI.leftBar.gaugeHpTyler.front:setStyleSheet([[
	background-color: RoyalBlue;
	padding: 1px;
]])
RoninMUDUI.leftBar.gaugeHpTyler.back:setStyleSheet([[
	background-color: gray;
]])

--Saros
RoninMUDUI.leftBar.gaugeHpSaros = RoninMUDUI.leftBar.gaugeHpSaros or Geyser.Gauge:new({name = "gaugeHpSaros", x = "10px", y = "-450px", width = "80px", height = "15px",
										message = "Saros", fgColor = "white",},RoninMUDUI.leftBar)
RoninMUDUI.leftBar.gaugeHpSaros.front:setStyleSheet([[
	background-color: RoyalBlue;
	padding: 1px;
]])
RoninMUDUI.leftBar.gaugeHpSaros.back:setStyleSheet([[
	background-color: gray;
]])
Image
Image

Thanks for all the hard-work that has gone into this amazing project! Mudlet kicks ass!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests