Register to post in forums, or Log in to your existing account

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion

Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Wed Aug 15, 2007 9:39 pm   

Changes to MXP Triggers in v2.0
In the upcoming v2.0 of CMUD, I have made some changes to MXP triggers that I hope people like.

First, CMUD 2.0 now supports the <tag/> format used in XHTML and XML.

But the bigger change is how CMUD handles undefined tags. In v2.0, your MXP Triggers will now fire on tags, even if they are unknown. For example, if you have the following MXP trigger defined:
#MXPTRIG {mytag} {#SHOW "tag fired:" %0}

then if the MUD sends:
This is a <mytag>test</mytag> of tags

then your trigger will fire, and you'll actually see this on the screen:
This is a testtag fired: test
 of tags

Notice that the trigger fires as soon as the closing tag is received. If the MUD sends:
This is a <mytag/>test of tags

then CMUD displays:
This is a tag fired: 
test of tags

Attributes also work. If you define your trigger like this:
#MXPTRIG {mytag} {#SHOW "tag fired:" %mxp.myattr}

and then the MUD sends:
This is a <mytag myattr="myvalue"/>test of tags

then CMUD would display:
This is a tag fired: myvalue
test of tags

Btw, this also fixes the bug with MXP triggers in v1.34 where %0 wasn't returning the full text between the opening and closing tag. This use of %0 isn't the same as normal scripts (normally %0 is the same as %-1). So I had to kludge CMUD a bit to maintain this feature. But it works in 2.0 now.

This should make it a *lot* easier for people to create MXP triggers to process XML text sent by some MUDs.
Reply with quote

Joined: 14 Aug 2004
Posts: 1241

PostPosted: Wed Aug 15, 2007 10:29 pm   
Wohoo! Very Happy
Reply with quote

Joined: 14 Aug 2004
Posts: 1241

PostPosted: Mon Aug 27, 2007 12:43 am   

Seb wrote:
Zugg wrote:
v2.01 supports the <tag/> format used in StormFront, and CMUD normally ignores unknown tags. You might try turning on the MXP debug mode to see the tags. In v2.01 you should be able to write MXP Triggers to fire on all of the tags now.

By "ignore" do you mean "ignores and gags" or "ignores and displays"? If it is "ignores and gags", then maybe there should be a preference to switch off the gagging of unknown tags... I think I'd rather create my own MXP elements (using the #MXP command) then for anything that looks like it might possibly be a tag to be gagged.

Zugg wrote:
What I mean is that it treats the tags just like any other HTML/XHTML tag that isn't supported in CMUD. For example, imagine handling the text


The way this should be handled by any web browser is that it should display the "Text" but not the actual tags. CMUD works just like a web browser for shows Text but not the tags.

OK, now consider the text:


What should it do now? Should CMUD display the <NewTag>? Even though there isn't yet a </NewTag> closing tag, how do we know whether or not this is a multiline tag, like <P>paragraph</P> in HTML? Unlike a web browser, CMUD doesn't have the entire "page" to just has a partial page as the text is received from the MUD. This is the issue with "scrolling HTML" support.

The way CMUD (and zMUD) have always handled this is to look at whether the MUD has put us into MXP Secure mode or not. In MXP Secure mode, CMUD assumes the MUD knows what it is doing and properly supports MXP. When a MUD properly supports MXP, then it should be sending


if it wants CMUD to explicitly display the < and > characters. In Secure mode, CMUD assumes that the MUD will eventually send the </newtag> closing tag, so the tag is stripped.

So, in MXP secure mode, any unknown tags are stripped (and cause MXP triggers to fire), but the text should be displayed normally. So CMUD should be gagging anything that looks like an open or closing tag, but not the text between them.

OK, that does make sense for the majority of cases, but I think it would still be handy to have a preference to switch off gagging of unknown MXP elements when not in MXP secure mode. For example, in this case, I would not want the tags stripped:

SomeFriend tells you 'Yeah, you need to make an MXP trigger on the Tell tag, which looks like this when you switch on XML mode: <tell>Xxxx tells you 'blah blah'[newline]</tell> - OK?'

Now, I wouldn't want the tags stripped in this case, and I can easily gag the text myself in my normal trigger (and I know that real tell tags always start at the begining of a line). (Gagging or not could even be an option of MXP triggers, possibly?) But I wouldn't want to use MXP triggers on my MUD, as they are currently implemented, because there is nothing to stop them firing on output that is caused by players - something I can more or less avoid if I use normal triggers to gag the text and store the text into variables, by putting a more restrictive pattern in the trigger. Not an ideal situation, and I have tried to persuade them to use MXP instead of XML, but without luck so far. Anyway, an option on MXP triggers to only fire when the opening tag is at the start of a line (or after another opening or closing tag that is at the start of the line) would be perfect for my MUD, since that is how they all are. Also, unfortunately, the closing tag(s) are always at the start of a line (or after another closing tag). This prevents me creating my own MXP elements and for the text to be properly captured by zMUD as being in that element, e.g. the RoomName element. Since multiline elements usually have to be in MXP secure mode, don't they? I don't know if this has changed in CMUD 2.01, but it doesn't look like it from what you have described so far?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by