Trigger filter, multiline, and deleteLine() question

Post Reply
RoninZero
Posts: 2
Joined: Thu Dec 28, 2017 1:49 pm

Trigger filter, multiline, and deleteLine() question

Post by RoninZero »

I have a rather annoying problem and I'm hoping some of the more experienced Mudlet users can assist me with.

My mud uses a special trigger string to make creating client based triggers easier.

For example, when there is a change in my vitals, my mud sends:
xxxxx_prompt 150 200 300 300 400 400

Which is in the following format "HP maxHP MP maxMP MV maxMV". There are a fair amount of these xxxxx_.* triggers in the game.
They all follow the same format of xxxxx_ followed by something, so instead of creating a trigger for each i decided it would be more efficient to use a trigger filter as such...
^xxxxx_ (perl regex)

then in that group I have added a trigger
prompt (\d+) (\d+) (\d+) (\d+) (\d+) (\d+).*$ (perl regex)

Code: Select all

echo(string.format("HP: %d/%d", matches[2], matches[3])
deleteLine()
This work beautifully, except *sometimes* the xxxxx_prompt is followed by an extra line which is not being deleted, thus causing excessive scrolling.
I've tried multi-line and fire length both inside and outside of the filter group, but can't see to remove the extra line if it present.

How do I delete the extra line if it's there?

I've tried multi-line and fire length both inside and outside of the filter group.

Thanx
-RZ

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

Re: Trigger filter, multiline, and deleteLine() question

Post by Vadi »

One way would be to use a tempLineTrigger() that'll go off on the next line only, check if it is blank and then delete it. Try that out, let me know if you get stuck!

RoninZero
Posts: 2
Joined: Thu Dec 28, 2017 1:49 pm

Re: Trigger filter, multiline, and deleteLine() question

Post by RoninZero »

Thanx Vadi!

It took some messing around but I finally got it working.....
Although it feels kinda wonky. (Don't worry, this will eventually be converted to events just trying to get used to Lua and Mudlet)

--RZ

Here is the result:
Code: [show] | [select all] lua
cur_hp = matches[2]
max_hp = matches[3]
cur_mana = matches[4]
max_mana = matches[5]
cur_move = matches[6]
max_move = matches[7]

clearWindow("My floating window")

echo("My floating window", string.format("\n<-- HP: %d/%d  MP: %d/%d  MV: %d/%d -->", cur_hp, max_hp, cur_mana, max_mana, cur_move, max_move))

-- Will fire 3 times with the next line, trying to remove blank lines
tempLineTrigger(1, 3, [[if line == "" then deleteLine() end]])

-- delete the initial trigger line actual 
deleteLine()


Post Reply