Grabbing info for HP guage

Post Reply
abrslam
Posts: 1
Joined: Tue Dec 13, 2016 1:29 pm

Grabbing info for HP guage

Post by abrslam »

Hello Mudlet people. I'm new to both muds and mudlet and I have zero programming experience. I'm working my way through the manual trying to setup a geyser gui. I'm able make and move boxes and stuff all over the screen but as of right now I've yet to be able to pull any data for my HP/SP/EP guages. Using the basic boxes from the manual I have the following.
Code: [show] | [select all] lua
hpbar = Geyser.Gauge:new({
  name="hpbar",
  x="42%", y="2%",
  width="15%", height="2%",})
hpbar:setValue(math.random(1,100),100)
This makes a lovely grey guage just where I want and just as big as I want. However I'm having a heck of a time figuring out how to get the data I need. I'm playing Threshold and I'm not sure what info I'm trying to grab. The manual reads as follows

"So for example, if you make a health bar - wherever you get your new health at (be it prompt, gmcp, atcp or whatever), update the gauge as well:"

It's the gmpc, atcp or whatever that confuses me. Do I pick one of these? Does it depend on my mud? Do have to setup seperate triggers to gather the info or does all the code go into this script? A push in the right direction is all I need.

Thanks.

[Moderator Edit: included "lua" tags around code to increase readability...]

Tesagk
Posts: 13
Joined: Sat May 28, 2016 12:04 pm

Re: Grabbing info for HP guage

Post by Tesagk »

Unless there's a Threshold player here, you're going to need to ask someone from the Threshold community. I don't know much about atcp, but gmcp is a way for the client (Mudlet) and the MUD (Threshold) to communicate with one another without showing up on your screen.

Which means that your client needs to send the request to get HP information from the MUD. A process that I believe depends on the MUD (the specific command that generates the request). Then you need to have a capture trigger for Mudlet that can receive the GMCP information.

Mudlet has that capability, but I've never used it, so I'll need to let someone with more experience step in for that bit.

Basically, you will need two "events" (likely triggers). One event will make the request upon a certain condition (timer; or a known change in health, such as taking damage). The other event will receive the information in the GMCP or ATCP method that your MUD delivers it in.

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

Re: Grabbing info for HP guage

Post by Jor'Mox »

If you are new to all of this, the easiest thing to do is just make a trigger to capture your prompt, and get the necessary values from there. If your prompt looks like the one in the video on the Threshold homepage, then you would use a pattern like this:
Code: [show] | [select all] lua
^HP\s+\[\s*(\d+)/(\d+)\s*\]\s+SP\s+\[\s*(\d+)/(\d+)\s*\]\s+EP\s+\[\s*(\d+)/(\d+)\s*\]
Set the pattern type for the prompt trigger to "perl regex", and then each time that trigger fires, it will capture the values from your prompt, allowing you to use them to set your gauges. Each of the values will be stored as follows:
Code: [show] | [select all] lua
current_hp = matches[2]
max_hp = matches[3]
current_sp = matches[4]
max_sp = matches[5]
current_ep = matches[6]
max_ep = matches[7]
So, to set the value for your hp bar, for example, you would just do this:
Code: [show] | [select all] lua
hpbar:setValue(matches[2],matches[3])
[Moderator Edit: Edited to include "lua" tags around code to increase readability...]

gesslar
Posts: 5
Joined: Mon Jul 29, 2019 9:18 pm

Re: Grabbing info for HP guage

Post by gesslar »

At this time, we're still on MudOS so we don't have GMCP. You would have to parse it from the bar that shows up whenever you type HP or whenever you receive the same information during combat. We are experimenting with FluffOS and GMCP which would allow someone to make health bars using that information, but, it's still experimental as we haven't even migrated to Fluff yet.

Post Reply