Multiline Triggers

Post Reply
mordenkaim
Posts: 6
Joined: Wed Apr 20, 2016 9:06 pm

Multiline Triggers

Post by mordenkaim »

Hi guys, I'm new to the forum but I am a long time zMUD user and experienced coder. I've just been dabbling in MUDs again and I ran across Mudlet. Very cool product so far.

I am trying to setup a multiline trigger to capture room descriptions for a mapper (following a simple example from another thread). In order to accomplish this I am filtering red text on black first and then creating a perl regex script that looks for a capital letter at the start of the line. These both work individually, but when I enabled multiline it does not apply the second rule. I have checked multiline and set the line delta to 1 to process lines 0 and 1 (see screenshot below). It may be that I'm misunderstanding how the gui is setup, but all I really need for this is it to apply both rules to the line with an AND condition. It is also grabbing red text at the end of the line that represents health, which should reject because the line starts with a {.
trigger.png
Thanks!
Mord

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Multiline Triggers

Post by SlySven »

Are you sure you need to set the line-delta to more than 0?

Also, if you want to grab the text I suspect you might want to use the predefined Lua table "matches[1]" which contains the entire line matched - or you could wrap the regexp bit you want in '(' & ')' and then extract them from "matches[x]" where x is 2 upwards from left to right (normally ?) for each "capture group" - though I could easily have something wrong as the lua/PCRE-fu is not strong in me!

mordenkaim
Posts: 6
Joined: Wed Apr 20, 2016 9:06 pm

Re: Multiline Triggers

Post by mordenkaim »

If I understand line delta properly it specifies the number of lines to check after the match occurs? If I am correct about that I do not need line delta greater than 0. I have not been able to find a lot on it googling. I was just playing with the value as I was not getting the expected results. Here is the output from a normal room.
roomOutput.PNG
roomOutput.PNG (12.15 KiB) Viewed 7047 times
My thought process is a multi-line trigger that looks for red text should isolate the description line, and then the line that looks for a capital letter at the start of the line should rule out any other random red text. There may still be a very off chance of a false positive but this was my first stab at it.

*EDIT* For some reason on that screenshot the HP number is showing white. It is red in game which was causing just a red text trigger to not work. There is also red used elsewhere so I'll need to get more specific with additional filtering. *END EDIT*

mordenkaim
Posts: 6
Joined: Wed Apr 20, 2016 9:06 pm

Re: Multiline Triggers

Post by mordenkaim »

Maybe this will be more clear...

With that trigger setup this is what I'm getting with highlight enabled.
roomOutputHighlight.PNG
roomOutputHighlight.PNG (13.02 KiB) Viewed 7043 times
If I have it set up as an AND trigger it should only highlight lines that are red (from the 1st condition) AND those that start with a capital letter (from the 2nd condition) but as you can see from the screenshot it is highlighting both.

Here's the current trigger, not much different than above except I am only looking for a capital letter. The only thing is I can't figure out why this is being processed as an OR instead of an AND.
trigger.PNG
trigger.PNG (14.25 KiB) Viewed 7043 times

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Multiline Triggers

Post by SlySven »

For comparison here is the settings I use for a MUD that is similar but uses Cyan Room names, (unfortunately so does communications from the MUDs Immortals so the room name capture is missing a regexp of something like:

^((?! speaks from the ).)*$

to filter THOSE out.) Note the second trigger where it uses setTriggerStayOpen(...) in the chain that keeps the first one open for one more line if "obvious exits:" is not seen in the current line after it has checked that the current line is NOT (another ?) room name line or a prompt line (with a "HP:" string):
roomNameDescriptionAndExit_1.png
roomNameDescriptionAndExit_2.png
roomNameDescriptionAndExit_3.png
I must confess I do not know exactly how it all works either - the above is what I have been able to deduce! :?

mordenkaim
Posts: 6
Joined: Wed Apr 20, 2016 9:06 pm

Re: Multiline Triggers

Post by mordenkaim »

Sorry, was out of town for the weekend so I haven't had a chance to look at this. It looks like I'd need to filter out all other sources of red text for this to work which may be cumbersome. (There are quite a few items with red text and some commands output red...who for example shows affiliation which can be red) I don't want to discount it completely, I just foresee a few potential pitfalls with Chalacyn as they are pretty liberal with red text.

Could you please copy/paste the code from those triggers into the forum? I wouldn't mind taking a look since we have similar output we are working with.

Is wotmud world of terris? I played the heck out of that back in the day when it was on AOL.

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Multiline Triggers

Post by SlySven »

Um, my code is not fully working - I have grafted an indexing system that I developed for a different client that hashes the room description and uses that and the room name to try and track the player location in real time (useful for the character that I have that can teleport) onto someone else's that supposedly auto-creates a map - and the construct is somewhat Frankensteinish at present (and some of the nuts are loose).

Basically I don't want to let this monstrosity out of my Lab yet. And, as I have only just restarted playing WheelOfTime MUD {game.wotmud.org:2224} after a break of a couple of years whilst hacking away at Mudlet, I'm still translating/assembling the whole system I had for a completely different Client I was using for it previously.

However, you may get some idea from the packages that are provided in the Mudlet package itself. I'll upload them here and you can load them individually into a dummy profile manually (use the module manager to load just one of them and see if it gives you any ideas). Two of them are automagically included as appropriate for some of the included MUDs. They are all .XML files so you will probably want to load them with that module manager rather than trying to pick through the raw XML...
mudlet-mapper.xml
For the 5 I.R.E. MUDs (Aetolia, Achaea, Imperian, Lusternia, and Midkemia)
(303.19 KiB) Downloaded 513 times
3k-mapper.xml
For 3Kingdoms and 3Scapes
(97.18 KiB) Downloaded 576 times
generic_mapper_script.xml
Basis for customisation for other MUDs
(24.79 KiB) Downloaded 497 times

Post Reply