Geyser UI Template

Share your scripts and packages with other Mudlet users.
Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Geyser UI Template

Post by Jor'Mox »

Between the two variables, put this: .. " : " ..
That is the quickest way to add in something like a colon, or any other string.

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

Re: Geyser UI Template

Post by Akaya »

1) Just as Jor'Mox said...
Code: [show] | [select all] lua
GUI.Willpower:setValue(tonumber(gmcp.Char.Vitals.wp), gmcp.Char.Vitals.maxwp, "<b>WillPower"..gmcp.Char.Vitals.wp..":"..gmcp.Char.Vitals.maxwp.."</b>")
2) gmcp.Char.Items returns a table. This is why you cannot echo it. You'll want to iterate through the table a bit to find what you're looking for. gmcp.Char.Items.List.items actually contains a table for each item in the room. So if we pull values from that to echo, it will work much better...
Code: [show] | [select all] lua
local t = {}
for k,v in pairs(gmcp.Char.Items.List.items) do
  table.insert(t, v.name)
end
GUI.Box7:echo(table.concat(t, "\n")
That should iterate through the list, grab all the names, and echo them to GUI.Box7.

Enjoy!

idrekdon
Posts: 1
Joined: Thu Jun 19, 2014 10:37 am

Re: Geyser UI Template

Post by idrekdon »

I'm new to LUA programming and also new to Mudlet.
Please help me with this.
I added a new script in mudlet and put this code:
Code: [show] | [select all] lua
myCurH = tonumber(gmcp.Char.Vitals.hp)
myCurM = tonumber(gmcp.Char.Vitals.mp)
myCurE = tonumber(gmcp.Char.Vitals.ep)
myCurW = tonumber(gmcp.Char.Vitals.wp)

myMaxH = tonumber(gmcp.Char.Vitals.maxhp)
myMaxM = tonumber(gmcp.Char.Vitals.maxmp)
myMaxE = tonumber(gmcp.Char.Vitals.maxep)
myMaxW = tonumber(gmcp.Char.Vitals.maxwp)

GUI.Health:setValue(myCurH, myMaxH, "<b>HEALTH "..myCurH..":"..myMaxH.."</b>")
GUI.Mana:setValue(myCurM, myMaxM, "<b>MANA "..myCurM..":"..myMaxM.."</b>")
GUI.Endurance:setValue(myCurE, myMaxE, "<b>ENDURANCE "..myCurE..":"..myMaxE.."</b>")
GUI.Willpower:setValue(myCurW, myMaxW, "<b>WILLPOWER "..myCurW..":"..myMaxW.."</b>")

I also put a User Defined Event Handler(gmcp.Char.Vitals) in it. The one just below the script name.

It does make the gauges update, but only at first. When I attack mobs, the gauge stay the way it is, it's always full, not moving, not updating its value. Can you tell me how can I make the gauges update?..

Thanks.

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

Re: Geyser UI Template

Post by Akaya »

You'll want to turn your script into a function and name your script the function name...
Code: [show] | [select all] lua
function updateGauges()
  myCurH = tonumber(gmcp.Char.Vitals.hp)
  myCurM = tonumber(gmcp.Char.Vitals.mp)
  myCurE = tonumber(gmcp.Char.Vitals.ep)
  myCurW = tonumber(gmcp.Char.Vitals.wp)

  myMaxH = tonumber(gmcp.Char.Vitals.maxhp)
  myMaxM = tonumber(gmcp.Char.Vitals.maxmp)
  myMaxE = tonumber(gmcp.Char.Vitals.maxep)
  myMaxW = tonumber(gmcp.Char.Vitals.maxwp)

  GUI.Health:setValue(myCurH, myMaxH, "<b>HEALTH "..myCurH..":"..myMaxH.."</b>")
  GUI.Mana:setValue(myCurM, myMaxM, "<b>MANA "..myCurM..":"..myMaxM.."</b>")
  GUI.Endurance:setValue(myCurE, myMaxE, "<b>ENDURANCE "..myCurE..":"..myMaxE.."</b>")
  GUI.Willpower:setValue(myCurW, myMaxW, "<b>WILLPOWER "..myCurW..":"..myMaxW.."</b>")
end
 
Then make the script name: updateGauges

Ruran
Posts: 3
Joined: Fri Jul 04, 2014 4:53 pm

Re: Geyser UI Template

Post by Ruran »

Okay, I need someone patient enough to explain these concepts to a 4-year old.

I've been using HTML5 for its simplicity after a long absence from the game, before which I did use Mudlet - but at that time the main GUI was the Achaea Fancy GUI (which I understood perfectly because I both used Nexus and help set it up for Mudlet). Now that both the AFGUI and HTML5 are found severely lacking in capability, I recognize my need to move up in the world.

However, after about an hour of fighting and swearing and getting practically nowhere, it's obvious I need a little help. I'm no stranger to LUA, but I'm completely unfamiliar with any form of CSS, and the sheer amount of new functions and scripts available in LUA have turned me into a newbie, and trying to set this up is fast approaching impossible. I don't know how to link the gagues with my actual health, putting the Mudlet mapper in Box1 works until I log out and log back in after which the map fills my entire screen and I can't do a thing, and if I attempt to remove any boxes or labels, they simply don't go anywhere. I know I'm doing something wrong, but I don't know enough to know what that is.

valaria
Posts: 17
Joined: Tue Dec 22, 2009 11:27 pm

Re: Geyser UI Template

Post by valaria »

i use this Geyser UI template on my mudlet. So i tried to set the text-align to top for the box2, however it didn't work and the vertical alignment of texts are still at center. where did I went wrong with that?
Code: [show] | [select all] lua
UI.Box2 = Geyser.Label:new({
  name = "GUI.Box2",
  x = 0, y = "50%",
  width = "50%",
  height = "50%",
},GUI.Right)
GUI.Box2:setStyleSheet([[
  background-color: rgba(0,0,0,100);
  border-style: solid;
  border-width: 1px;
  border-radius: 10px;
  border-color: green;
  margin: 10px;
  text-align:top;
]])

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

Re: Geyser UI Template

Post by Akaya »

At first glance, you have UI.Box2 instead of GUI.Box2 Not sure if the 'G' was cut off when you copy+pasted though.

Aside from that, use qproperty-alignment instead of text-align in your stylesheet...
Code: [show] | [select all] lua
GUI.Box2:setStyleSheet([[
  background-color: rgba(0,0,0,100);
  border-style: solid;
  border-width: 1px;
  border-radius: 10px;
  border-color: green;
  margin: 10px;
  qproperty-alignment: 'AlignTop';
]])

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

Re: Geyser UI Template

Post by Akaya »

@Ruran To attach a gauge to your health, you'll need a variable to track your health. Each time your health changes, set the value of the gauge to reflect your new health. Here's a small example...
Code: [show] | [select all] lua
myHealth, myMaxHealth = 50, 100
GUI.Health:setValue(myHealth, myMaxHealth)
As for your mapper problem, posting the script you're using would be helpful.

Ruran
Posts: 3
Joined: Fri Jul 04, 2014 4:53 pm

Re: Geyser UI Template

Post by Ruran »

Akaya wrote:you'll need a variable to track your health.
That, I can understand. But how do I grab that value from GMCP?
Akaya wrote:As for your mapper problem, posting the script you're using would be helpful.
As for that, it was your own. The very first post in this thread, in the section where you talk about Box1 being a good place for the mapper. I just replaced the script for Box1 with the script provided there, and that happens. Clearly, this is the wrong thing to do, but I don't understand containers well enough to know the right thing to do.

sbgamer
Posts: 2
Joined: Sun Jul 06, 2014 11:41 pm

Re: Geyser UI Template

Post by sbgamer »

Akaya wrote:
Code: [show] | [select all] lua
local t = {}
for k,v in pairs(gmcp.Char.Items.List.items) do
  table.insert(t, v.name)
end
GUI.Box7:echo(table.concat(t, "\n"))
That should iterate through the list, grab all the names, and echo them to GUI.Box7.
have tried using this script (closed it so it would run)

One problem I am having is that it is not iterating a new line for every object in the room. I am also having a problem with it not updating when I move from room to room.

Questions:

1. Do I need to create a script that empties and reloads this table every time I move?
2. I tried tying it to a gmcp event handler "gmcp.Char.Items.List.items", and that will update it if I load the script manually, am I on the right track with this?
3. How would I make it iterate each object in the table on a fresh line?

Sorry, I am brand new to lua, and to most programming, so please take it easy with me

Post Reply