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
struesdell
Beginner


Joined: 30 Nov 2006
Posts: 11
Location: Seattle, WA, USA

PostPosted: Thu Nov 30, 2006 6:46 pm   

[1.17] MXP question
 
So far, I'm lovin' CMud's interface improvements, and I like that it's making me script smarter. However, this one has me stumped.

In ZMud, the following worked perfectly.
Code:

#TRIGGER {(%w)(%d)} {#SUBSTITUTE {~<send "#var target %2|p %2|buy %2|wp %2|wield %2|unwield %2|get %2" "Target|Probe|Buy|Weaponprobe|Wield|Unwield|Get"~>%1%2~</send~>}}

and was super awesome. However, when I drop the same thing into CMUD, all it only shows one menu item, and activating it performs only the #var command without parameters.


ZMud - creates 7 menu items, using a command from the first set with a menu title from the second set.


CMud - creates 1 menu item, using the command from the first word and the menu title from the second word, then stops.


I'm not sure why they'd be different, since it's been said elsewhere on this forum that the MXP stuff is the same as in ZMud. I'm guessing it has to do with a syntax or parsing change. It seems like CMud is chopping off the substitution after ~<send "#var target

Honestly though, I got this script from someone else, and added a tiny bit to it in ZMud before I decided to try to use CMud. I don't really know anything about how the above is working with MXP.

Can anyone help me debug it, and get CMud to do what I loved ZMud doing?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Nov 30, 2006 7:06 pm   
 
You don't need to quote the <> characters any more. They aren't special characters in CMUD. You also need to quote the "" characters, because they'll change your list into a string rather than a parameter of the MXP tag. Here's what it looks like with the fixes:

#SUBSTITUTE {<send ~"#var target %2|p %2|buy %2|wp %2|wield %2|unwield %2|get %2~" ~"Target|Probe|Buy|Weaponprobe|Wield|Unwield|Get~">%1%2</send>}

and it works fine for me. Before, because CMUD's parser was removing the "" it was seeing "<send #var target" and interpreting #var as the command list and target as the label list. Any other parameters were ignored. Once they're quoted out so CMUD's parser skips them, the MXP will interpret the parameters properly, with the string list of commands as the commands and the string list of labels as the labels.

If it were my script, I'd replace the wildcards with the ($localvar:%wildcard) syntax to get rid of the nasty nasty %nns, but that's just me ^_^
Reply with quote
struesdell
Beginner


Joined: 30 Nov 2006
Posts: 11
Location: Seattle, WA, USA

PostPosted: Thu Nov 30, 2006 7:22 pm   
 
Alright, so you might change it to

#TRIGGER {($obj:%w)($objnum:%d)} {#SUBSTITUTE {<send ~"#var target $objnum|p $objnum|buy $objnum|wp $objnum|wield $objnum|unwield $objnum|get $objnum~" ~"Target $obj|Probe $obj|Buy $obj|Weaponprobe $obj|Wield $obj|Unwield $obj|Get $obj~">$obj$objnum</send>}}

to get rid of the repeated calls to the various %1..99s.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Nov 30, 2006 7:24 pm   
 
Yep. That'll also change the labels to have the name of whatever it is on them, too.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
struesdell
Beginner


Joined: 30 Nov 2006
Posts: 11
Location: Seattle, WA, USA

PostPosted: Thu Nov 30, 2006 7:28 pm   
 
Any way to capitalize the first letter of $obj before displaying it in the labels?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Nov 30, 2006 7:59 pm   
 
Does %proper($obj) work?
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
struesdell
Beginner


Joined: 30 Nov 2006
Posts: 11
Location: Seattle, WA, USA

PostPosted: Thu Nov 30, 2006 8:01 pm   
 
Nope, instead using %proper($obj) seems to leave the Labels with no reference to $obj at all.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Nov 30, 2006 8:21 pm   
 
Easiest way if that doesn't work would be to add

$obj=%proper($obj)

before the #sub command, then, making

#TRIGGER {($obj:%w)($objnum:%d)} {$obj=%proper($obj);#SUBSTITUTE {<send ~"#var target $objnum|p $objnum|buy $objnum|wp $objnum|wield $objnum|unwield $objnum|get $objnum~" ~"Target $obj|Probe $obj|Buy $obj|Weaponprobe $obj|Wield $obj|Unwield $obj|Get $obj~">$obj$objnum</send>}}

Weirdly, this code doesn't work on the command line, but works fine in the settings window.

If you want to keep the $obj part of $obj$objnum lowercase, just stick %lower round it - if you don't want to do that, you could change the aforementioned addition to $Pobj=%proper($obj) and change all the $obj references manually.
Reply with quote
struesdell
Beginner


Joined: 30 Nov 2006
Posts: 11
Location: Seattle, WA, USA

PostPosted: Thu Nov 30, 2006 9:28 pm   
 
Thanks for the help, this is all working for me now, and I think I understand it well enough to troubleshoot further special character problems in converting my scripts.
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