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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed May 23, 2007 4:23 am   

[1.33] Trouble parsing with #MXP
 
#MXP has trouble parsing if the first parameter is %1.

Consider

#REGEX {^[\s*(\d+)] ((\a+ )+)(\s+)(\d+ .+)$} {
#MXP %1 <send ~"buy %3~" ~"buy~">%trim(%3)</send>%5 <send ~"buy %3~" ~"321 bits~">%6</send>
}
_________________
Asati di tempari!
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed May 23, 2007 4:51 am   
 
Confirmed. The syntax highlighting isn't using the pink that it normally does for %n variables - instead it's making the % green and the 1 orange, which I guess means the parser is identifying it wrong. I also tried testing using "#mxp {text %1}" and that didn't work either - no colouring at all.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


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

PostPosted: Wed May 23, 2007 5:43 pm   
 
The #MXP command was originally added for internal testing purposes. The first argument of #MXP is actually a hidden argument that allows you to override the secure/open setting being used. Essentially, the first argument is the numeric value used in the ESC [ nn z MXP code that is sent at the beginning of the line. The default value of "nn" is 1, which outputs the MXP in secure mode.

That is why it's important to put {} around the entire argument so the #MXP command doesn't try to parse the first argument as this numeric "nn" code.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed May 23, 2007 7:22 pm   
 
Ok that leads to a second question... maybe I'm daft ( or Shocked didn't search properly ) but I didn't see a way to generate an active tag (i.e. I can click on it and it works) using PSUB or SUB.

The best I was able to was to get the text generated, but it didn't look like the tag was interpreted as an MXP tag. Am I missing or should I just keep searching the forums.

I know Fang is quick with these types of questions, any input?
_________________
Asati di tempari!
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 23, 2007 8:06 pm   
 
$temp={Preform <send 'action1 %1|action2 %1|Action3 %1|action4 %1' 'Action One|Action One|Action Two|Action Three|Action Four'>action</send> on %1}
#SUB {$temp}
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed May 23, 2007 9:42 pm   
 
That is soo obvious I'm not sure why it didn't occur to me before... It also makes me wonder why the direct substitution doesn't work.

Plus it plays into the fact that I eventually want to modify it recreate the ansi colors using MXP colors so I don't lose the information.
_________________
Asati di tempari!
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Wed May 23, 2007 10:54 pm   
 
Oh, it can be done directly but it is a LOT uglier and really not worth the trouble when you can make it look so pretty this way.

It's been a while since I did it directly though so forgive me if I happen to have forgotten the syntax!
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed May 23, 2007 10:56 pm   
 
Now is it possible to do it for a partial line. Consider the same trigger.

And the input line is this.

Code:
[100]  Belt of dwarven sturdiness      16 Royal Sunbursts, and 1 mithril Pentacle


Now I'm checking to see I am at the right level for the eq. if I am below, I only want to highlight the cost "16 Royal Sunbursts, and 1 mithril Pentacle" so I can see the converted i.e. numerical version of it.

I'm trying this
Code:
$money={<send ~" ~" ~"321 Bits~">%trim(%6)</send>}
#PSUB {$money} %x6


But it isn't being treated as an MXP tag though. Ideally I want the results to look like

Quote:
[100] Belt of dwarven sturdiness 16 Royal Sunbursts, and 1 mithril Pentacle


But instead I'm getting

Quote:
[100] Belt of dwarven sturdiness <send " " "321 Bits">16 Royal Sunbursts, and 1 mithril Pentacle</send>
_________________
Asati di tempari!
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu May 24, 2007 6:59 am   
 
Ok... it doesn't look like it can be done directly (perhaps this should be a feature request).

But I worked around it by enabling a second trigger that just matches the end and does the sub on that portion so I end up with something like this.

Code:
#REGEX {(\d+ .+)$} { $money={<send ' ' 'The price is 321 Bits'>%trim(%1)</send>}
#sub  $money}


In my first trigger I do an if check, if I don't meet the level requirements I enable this second trigger otherwise I just do the original SUB.

Now to work on my ANSI color matching and subbing.

P.S. I know I've kinda hijacked this topic now, but I thought I'd post the solution for someone who searches the forum in the future.
_________________
Asati di tempari!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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 Wolfpaw.net