I'm doing it wrong!

Post Reply
Aydein
Posts: 27
Joined: Wed Sep 13, 2017 8:45 pm

I'm doing it wrong!

Post by Aydein »

Okay, so normally I can figure just about anything out. I built my own GUI (to go on record, I do not play any of the IRE MUD currently.) for a MUD I've been playing and I'm continuing to make it better, but I ran into a snag with my gauges. Actually to be accurate, it's not the gauges themselves, I'm finding out quickly that regular expressions in perl regex are the bane of my MUD life existence.

<100%hp 83m 100%mv>

This is my prompt. I want to capture both the hp and mv numbers and store them as a variable, but I cannot get them to capture via a trigger. I'm fairly certain it's my regular expression. I've tried a few different things, such as ^<(\d+)%hp (\d+)m (\d+)%mv>$ amongst other things. I did flip the drop down on the right to perl regex, just to eliminate that as a potential suspect to my problem.

I'm interested in both what I did wrong and how to do this correctly.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: I'm doing it wrong!

Post by Vadi »

https://regex101.com/r/JtDs9W/1 it matches just fine, except in the prompt you pasted you've got a blank space at the end of it that your regex doesn't account for. Was that it?

Aydein
Posts: 27
Joined: Wed Sep 13, 2017 8:45 pm

Re: I'm doing it wrong!

Post by Aydein »

Yeah, I just tried the above as well. Something is still going wrong.
This is my prompt, nothing else is on the line.

<100%hp 31m 100%mv>

Is there a way that I should be accounting for that space? It's there in the MUD itself. Every prompt is on a line by itself. I really don't understand where I'm going wrong with this one. It seemed like a no brainer but matching this prompt has collectively given me more trouble than the rest of my GUI.

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

Re: I'm doing it wrong!

Post by Jor'Mox »

Just drop the $ from your regex, and it should be fine.

Aydein
Posts: 27
Joined: Wed Sep 13, 2017 8:45 pm

Re: I'm doing it wrong!

Post by Aydein »

That worked! Thank you.

Aydein
Posts: 27
Joined: Wed Sep 13, 2017 8:45 pm

Re: I'm doing it wrong!

Post by Aydein »

**EDIT** I finally figured it out. Thank you all for your help!

I've run into another problem, but I think this is just another issue of my doing it wrong.

I'm trying to update my gauges based on my prompt.
My trigger is capturing the variables current health

Should this be what my script box of my trigger looks like, or do I update the gauge another way?

Code: Select all

current_health = matches[2]
max_health = 100
current_mv = matches[4]
max_mv = 100

hpbar:setValue(current_health, max_health)
mvbar:setValue(current_mv, max_mv)
Should I place my setValue with the health bar script? I assumed by the wording of the geyser manual that I would place this with the trigger so that when it updates the variable it would also update the gauge. Am I wrong? I can post my gauge code too, if need be.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: I'm doing it wrong!

Post by Vadi »

Looks right, though one tricky thing is that you want to convert the captured data to numbers:
Code: [show] | [select all] lua
current_health = tonumber(matches[2])
max_health = 100
current_mv = tonumber(matches[4])
max_mv = 100

hpbar:setValue(current_health, max_health)
mvbar:setValue(current_mv, max_mv)
I'd recommend starting a new thread for a problem to avoid this turning into a neverending megathread :)

Post Reply