Parse from Mud that sends data in xml

Post Reply
Lightbender
Posts: 4
Joined: Fri Jul 24, 2020 7:37 pm

Parse from Mud that sends data in xml

Post by Lightbender »

My mud will send data in ansi or xml format. It doesn't do any of the other powerful formats.

However I would like to take advantage of the fancy capabilities that xml provides like seeing whether something is a monster or a player. However, I don't see a way to have Mudlet automagically parse the xml like it does for the ansi (color).

The big trouble is how to parse multiline messages.

An example room with things going on:

Code: Select all

<short>The village green</short><exit> <e w n s></exit>.
<long>You are in a large open grassy place just south of the village church, which
dominates the scene. The main village lies over to the east and Ingis lane
leads off south. To the west, there is a humpback bridge crossing a wide
river, and beyond that, untamed wilderness.
It is evening and the gloom is spreading.</long>
<exit>  There are four obvious exits: east, west, north and south.</exit>
<monster>An ok Lumberjack.</monster>
<prompt>> </prompt>
For this I want to detect anything that has both open and close brackets and then do things with the Text. So in this case I would Identify <short> ... </short> as an xml content but wouln't identify <e w n s>.

I want to gag the xml tags, color the text between the xml tags, pass text for some tags (such as tells) to a script, etc.

If this was all on one line I could use a very easy regex to capture these. But in Mudlet the regex fails if there are multiple lines. For instance how do I capture the long description with a regex trigger, change the color and drop the tags.

Code: Select all

<long>You are in a large open grassy place just south of the village church, which
dominates the scene. The main village lies over to the east and Ingis lane
leads off south. To the west, there is a humpback bridge crossing a wide
river, and beyond that, untamed wilderness.
It is evening and the gloom is spreading.</long>

Post Reply