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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sat Mar 08, 2008 1:25 am   

#add outfit %1
 
I cant seem to get %1 from a equ list

[ left finger ] [100] Olog'Hai Signet Ring
[ right finger ] [100] Olog'Hai Signet Ring
[ neck 1 ] [100] Pendant of Spirits
[ neck 2 ] [100] Pendant of Spirits
[ torso ] [100] the body armor of the Purple Dragon
[ head ] [100] a Kingly Crown


Tried this
Pattern: [ left finger ] [(%d)] (%w)
#add outfit %2

but I dont get %2, dont care what %d is, but that can be 1 to 100, so using %d

I have a feeling its the [ ] in the pattern, but I dont know how to handle them
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sat Mar 08, 2008 1:49 am   
 
You are correct that it is the [ and ]'s that are causing the problem.

Just use a tilda, "~", before them to make Zmud see them as ordinary characters instead of special ones.

~[ left finger ~] ~[(%d)~] (%w)
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Mar 08, 2008 1:52 am   
 
Small changes to the pattern to correct it to match. Since you didn't care what the %d was I remove the capture of it. Anchored the pattern to both start and end of line, the end of line anchor is mostly superfluous, but I think there is an optimization in the matching engine that uses it. I also adjusted the final capture to pick up all words.

The #ADD command does both numeric computation and concatenation. Since you are passing it text it would preform a concat, however you supplied no seperator in your script. The lack of a seperator would make it hard to determine which words should be grouped together or which characters formed a word. Considerthissentenceandshouldfinditisnothardtoreadsinceyoucanparsethemeaningofwords. The change to #ADDITEM provides a seperator that is used in many other commands and functions, and will work much better for you.

Pattern: ^~[ left finger ~] ~[%d~] (*)$
#ADDITEM outfit {%1}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sat Mar 08, 2008 1:30 pm   
 
Thanks to both of you for repling to this post. However, I tried both of your samples and I'm still not able to populate the 'outfit' variable.

I tested the pattern and it returns pattern matches but nothing is added to 'outfit'
Reply with quote
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sat Mar 08, 2008 2:16 pm   
 
Well correction to this, things seem to work after you walk away for a few. I got it working to some degree using Arminas example.

It only adds the first word of the string tho, ie "Olog'Hai" from "Olog'Hai Signet Ring" which will work

Note: to get to work, I had to insure the spacing was correct where blank spaces are found.

Thanks again guys, you guys rock
Darklord
Reply with quote
JQuilici
Adept


Joined: 21 Sep 2005
Posts: 250
Location: Austin, TX

PostPosted: Sat Mar 08, 2008 2:30 pm   
 
Ok...let's boil this down to essentials:

  1. Start zMUD
  2. Hit ESC to dismiss the session window and start an empty session in offline mode
  3. Type the following at the command line, and hit return:
    Code:
    #trig {^~[ * ~] ~[%d~] (*)$} {#additem outfit {%1}}

    Note that I'm throwing away both the slot name (the * in the first set of brackets) and that numeric code (the %d in the second set of brackets). If you want to keep either one, put parens around it and shift the %n numbers appropriately.
  4. Hit Ctrl-R to turn off command parsing on the command line (so we can paste in your sample output w/o escaping all the special characters)
  5. Paste the sample output into the command line and hit return:
    Code:
    [ left finger ] [100] Olog'Hai Signet Ring
    [ right finger ] [100] Olog'Hai Signet Ring
    [ neck 1 ] [100] Pendant of Spirits
    [ neck 2 ] [100] Pendant of Spirits
    [ torso ] [100] the body armor of the Purple Dragon
    [ head ] [100] a Kingly Crown

  6. Hit Ctrl-R again to turn command parsing back on
  7. Type the following at the command line, and hit return:
    Code:
    #show @outfit


When I do that, I get the following output:
Code:
Olog'Hai Signet Ring|Pendant of Spirits|the body armor of the Purple Dragon|a Kingly Crown

...which looks about right.

One note: it is important to use the curly braces around the %1 in the trigger body, so that multiple-word items are added correctly (rather than just the first word of the item).

Second note: #additem suppresses duplicates - if you want to include the duplicates in the list twice, the trigger should instead be:
Code:
#trig {^~[ * ~] ~[%d~] (*)$} {outfit=%additem({%1},@outfit)}

which results in the following value of @outfit:
Code:
Olog'Hai Signet Ring|Olog'Hai Signet Ring|Pendant of Spirits|Pendant of Spirits|the body armor of the Purple Dragon|a Kingly Crown


EDIT: Heh...looks like we crossposted. Check my notes for the solution to your first-word problem. Smile
_________________
Come visit Mozart Mud...and tell an imm that Aerith sent you!
Reply with quote
Darklord
Beginner


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sun Mar 09, 2008 3:30 pm   
 
Thanks again guys, whats the best way to remove, 'the', 'a', 'an', 'some' from {%1} if it appears at the start of {%1}
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Mar 09, 2008 3:42 pm   
 
var=%subregex(%1,"^(a|an|the|some) ","")
_________________
Rorso's syntax colouriser.

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


Joined: 29 Jan 2008
Posts: 17

PostPosted: Sun Mar 09, 2008 3:50 pm   
 
I love this place, yall are the best.

Fang that worked fine until it sees an item begins with 'a' so I
var=%subregex(%1,"^(a |an |the |some ) ","") added a space after each.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Mar 09, 2008 4:02 pm   
 
You'll want to remove the space at the end in that case, or it won't match - there'll be two spaces in a row, which don't occur in the text.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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 Wolfpaw.net