Page 1 of 4

PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 12:16 am
by trentont101
HOWDY THERE!!!

I am a very noob programmer and while I am pretty computer savvy, I am really struggling setting up a HP bar on my MUD profile.. YES I have read the article and NO I dont understand it :)
Here is my bar, I know... it looks exactly like the example... well this is where I am confused. How do I define the variables current_health and max_health??
how can I keep them current every time my prompt is read to the screen
would I use a trigger? if so how would i set the trigger to look for THOSE number?
also. I am about to post some mapping questions as well, if you are smart as heck give that a read too, you might just make my day!!

Thanks for any help you can give!!!!
MUD ON!

my prompt is as follows

"currenthealth/maxhealth >"


hpbar = Geyser.Gauge:new({
name="hpbar",
x="60%", y="20%",
width="45%", height="5%",
})
hpbar:setValue(current_health,max_health)

ERROR::::
Attempt to compare nil with number

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 9:05 pm
by icesteruk
how do you track currethealth and maxhealth??

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 9:22 pm
by trentont101
that is my questions ha,
on my mud i have a prompt
currenthealth / maxhealth >
obviously both change

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 9:30 pm
by icesteruk
you have to track it, as in use GMCP or another way to track your health..

like Do you have a sipper for health/mana?

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 9:46 pm
by Jor'Mox
So, first you need a trigger to capture your prompt. Since your prompt is as you have described it, you should be able to use this as a pattern for the trigger: ^(\d+) / (\d+) >$
Note that the pattern given assumes your prompt looks like this:
100 / 500 >
If it is any different (other than having different numbers), then it needs to change to match what you see.
The code your trigger needs to execute is this:
current_health = matches[2]
max_health = matches[3]
hpbar:setValue(current_health or 0,max_health or 1)

You should change the place where you are declaring your health bar to match the line above, so that it doesn't have issues with nil values. If that doesn't work, let me know.

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 10:08 pm
by trentont101
Ok i am trying to keep up but struggling. You might have to dumb this down a bit but first..
CHEERS FOR YOUR RESPONSE!!! thank you!!
ok so
^(\d+) / (\d+) >$ goes in area 0 of a trigger matching a substring? so i need to mark "match all" "filter" multiline and triggER"

then
current_health = matches[2]
max_health = matches[3]
hpbar:setValue(current_health or 0,max_health or 1)


that goes in the bottom box of the trigger thing.

save it up, call it health,

now my script looks like this


hpbar = Geyser.Gauge:new({
name="hpbar",
x="60%", y="20%",
width="45%", height="5%",
})
current_health = matches[2]
max_health = matches[3]
hpbar:setValue(current_health or 0,max_health or 1)
current_health, max_health = tonumber(matches[2]), tonumber(matches[3])


any registered event handlers or whatever?

in this configuration now there is no nil error, but it is not working.

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 10:27 pm
by Jor'Mox
You need to change the trigger type to regex, instead of substring. There is no need for the check boxes you mentioned to be checked. And you don't need the lines using "matches" in the definition portion of your script.

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 10:33 pm
by trentont101
Ok , it is set up correctly, still not working, i will take a break and work on it some more in a bit any more ideas?

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 10:45 pm
by Jor'Mox
Can you post a screenshot of the trigger and the script that you have? Sometimes it is easy to miss something when debugging if I can't actually see it.

Re: PLEASE HELP!!!! Using Gyser to create a HP bar

Posted: Fri Jan 17, 2014 11:02 pm
by trentont101