With a lot of help from Vadi, I managed to get MXP-style links working last night. I actually send the data in a slightly different format for Mudlet, to make it easier to parse.
The trigger looks for the following pattern: \t<send>(.*)</send>
This executes the following script:
Code: Select all
selectCaptureGroup(1)
setUnderline(true)
setFgColor(255,255,255)
replace(matches[2])
setLink([[send("]]..matches[2]..[[")]], matches[2])
deselect()
resetFormat()
I then have a couple of similar triggers for the other send formats. In this screenshot you can see what it looks like in action:
The underlined bold text is all clickable, and you can hover over it with the mouse to see what happens when you click.
There are still two issues I'm having trouble with though. The first is the colouring - Vadi explained to me last night that colour is stripped when the text is replaced, and that I could use functions to find the colour and then set the colour manually. I've tried doing this without much success, so I think I will have to send the rgb value with the link - not a major problem, although it may take some tweaking to ensure I get the right colours. For now I just colour everything white.
The second problem is a bit more strange. It seems that the clickable text is equal to the length of the pattern rather than the highlighted part. So for example if I have the following:
"You can type '<send>score</send>' to view your current attributes at any time."
Then this will be currently displayed as:
"You can type '
score' to view your current attributes at any time."
However you can actually click on the link
as if it were highlighted as:
"You can type '
score' to view your current attributes at any time."
I.e., it includes the length of the "<send>" and "</send>" when calculating how long the clickable part of the text should be.
It's still usable, but could cause conflicts if I have multiple links on the same line.