regex tomatch prompt when HP<100?

Post Reply
Beven
Posts: 5
Joined: Thu Oct 10, 2013 4:11 pm

regex tomatch prompt when HP<100?

Post by Beven »

I would have thought this would be trivial, but I must be stupid. read the regex tutorials, still can't figure it out....
prompt looks like :
[221/221hp 110/110m 101/101v (8605)]>

just need to pop a trigger when hp is less than 100

Am I just stupid or is this harder than it sounds like it should be?

Tagon
Posts: 24
Joined: Thu Sep 19, 2013 8:38 pm

Re: regex tomatch prompt when HP<100?

Post by Tagon »

Personally I'd regex to get the current hp then use lua to test if it's lower than 100.

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: regex tomatch prompt when HP<100?

Post by Belgarath »

Code: [show] | [select all] lua
Regex: ^\[(\d+)/(\d+)hp (\d+)/(\d+)m (\d+)/(\d+)v \((\d+)\)\]
That'll match the prompt. You can capture the health and check if it's less than 100 with:
Code: [show] | [select all] lua
local hp = tonumber(matches[2])
if hp < 100 then
   echo("You gunna die")
end

Post Reply