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


Joined: 24 Jul 2009
Posts: 14

PostPosted: Sat Apr 30, 2011 4:17 pm   

Old Zmud organizing script conversion
 
Hello again folks!

Working version here! Thanks Shalimar and Rahab!

Code:

#TR {It contains:} {#GAG}
#COND {(*).} {
  $Contents=%replace(%replace(%1, ", and ", "|"), ", ", "|")   
  $Contents=%countlist($Contents)
  #SUB {<color grey>You see~:</color>}
  #LOOPDB  $Contents {#IF (%val = 1) {#SHOW %key} {#SHOW %key ~(x%val~)}}
}


Last edited by mtuyooper on Thu May 19, 2011 10:50 am; edited 3 times in total
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Sat Apr 30, 2011 7:56 pm   
 
http://forums.zuggsoft.com/forums/viewtopic.php?t=1399
http://forums.zuggsoft.com/forums/viewtopic.php?t=13641
_________________
Discord: Shalimarwildcat
Reply with quote
mtuyooper
Beginner


Joined: 24 Jul 2009
Posts: 14

PostPosted: Sat Apr 30, 2011 10:08 pm   
 
Ahh excellent! That's almost exactly what I'm looking for. One thing that is throwing me though...

Quote:

The output must all be on a single line, which can be a line wrapped by zMUD.


In my case it is shown as :
Quote:

It contains:
Item, item, item, item.



Which has the info I'm interested in on the next line. How should I parse it to grab it next?

Thanks!
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Sat Apr 30, 2011 10:37 pm   
 
Since all you want the first line to do is get replaced with dashes it is simple:
Add a trigger state for the second line that has all the important code, just like your original
_________________
Discord: Shalimarwildcat
Reply with quote
mtuyooper
Beginner


Joined: 24 Jul 2009
Posts: 14

PostPosted: Sun May 01, 2011 12:24 am   
 
OK, so I would use the #COND as per the original example?

I'm using :

Code:


#tr It contains:
#GAG
#COND {(*).}
  TempContents={%1}
  #VAR TempContents  %replace(  %replace( {@TempContents}, ", and ", "|"), ", ", "|")
  TempContents=%countlist(  @TempContents)
  #SUB {%ansi(grey) You see~:}
  #LOOPDB  @TempContents {#IF (%val = 1) {#SHOW %key} {#SHOW %key ~(x%val~)}}



It returns {%1} illegal token...

I'm not sure where I've gone wrong.

Also tried... :
Code:

#tr It contains:
#cond {(*).}
#VAR contents {%1}
#VAR contents  %replace( {@contents}, ", and ", "|")
#VAR contents  %replace( {@contents}, ", ", "|")
#VAR contents  %countlist( {@contents})
ContentsSummary

#al ContentsSummary #SAY Inside you see;#LOOPDB  @contents {#SAY %val %key}



Thank you for the help Shalimar, much appreciated![/code]
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri May 06, 2011 5:56 pm   
 
This is another perfect example of how GMCP could be extremely useful. Does your MUD use it? I know with IRE you can simply request a contents list of any container. Just a thought...
Reply with quote
mtuyooper
Beginner


Joined: 24 Jul 2009
Posts: 14

PostPosted: Tue May 17, 2011 6:45 pm   
 
Unfortunately I don't believe the mud does. Nor have I had any luck with this issue.

Anyones thoughts on how to proceed in order to organize the contents would be greatly appreciated!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue May 17, 2011 8:05 pm   
 
I think you have a syntax error in your #COND statement. You forgot to put braces around the code that goes into the condition statement. You need:
Code:

#COND {(*).} {
  TempContents={%1}
  #VAR TempContents  %replace(  %replace( {@TempContents}, ", and ", "|"), ", ", "|")
  TempContents=%countlist(  @TempContents)
  #SUB {%ansi(grey) You see~:}
  #LOOPDB  @TempContents {#IF (%val = 1) {#SHOW %key} {#SHOW %key ~(x%val~)}}
}
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Tue May 17, 2011 8:38 pm   
 
it needs braces around the trigger pattern/value as well
Since we are updating to CMUD, might as well use local variables as well

Code:
#TR {It contains:} {#GAG}
#COND {(*).} {
  $Contents=%replace(%replace(%params, ", and ", "|"), ", ", "|")     
  $Contents=%countlist($Contents)
  #SUB {<color grey>You see~:</color>}
  #LOOPDB  $Contents {#IF (%val = 1) {#SHOW %key} {#SHOW %key ~(x%val~)}}
}
_________________
Discord: Shalimarwildcat
Reply with quote
mtuyooper
Beginner


Joined: 24 Jul 2009
Posts: 14

PostPosted: Wed May 18, 2011 2:40 pm   
 
Most excellent thank you Rahab and Shalimar!

It captures the very last item, the one with the period next to it. For example :

It contains:
45 pieces of wood, a bottle of beer.

And returns :
You see:
beer.

Am I not structuring my wild card properly? Do I need to buffer the * in some way?

Edit : IT also creates a sub entry of the trigger for the state *. after every use of the trigger.

Long time no see Rahab, Dart anymore?

Thank you folks!
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed May 18, 2011 4:14 pm   
 
If you are using Shalimar's code, then I see why it is including the period. Change this line:
Code:
$Contents=%replace(%replace(%params, ", and ", "|"), ", ", "|")

to this:
Code:
$Contents=%replace(%replace(%1, ", and ", "|"), ", ", "|")


No, I'm afraid I haven't been on Dartmud in years.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Wed May 18, 2011 4:52 pm   
 
%params and %1 should be the same for a given pattern of {(*).} no?
_________________
Discord: Shalimarwildcat
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu May 19, 2011 12:56 am   
 
I don't see anything in the documentation to suggest that %params is even defined for a trigger pattern. If it is, I would expect it to be the equivalent of %line. The fact that it is capturing the period pretty is strong evidence.
Reply with quote
mtuyooper
Beginner


Joined: 24 Jul 2009
Posts: 14

PostPosted: Thu May 19, 2011 10:45 am   
 
Thank you Rahab and Shalimar!

The change you stated Rahab made all the difference. Finished code is below!

For other people, this takes input from a container and reorganizes it into a more eyeball friendly package. It is used when the data you are interested in begins on a new line, unlike some of the examples above which began on the same line.

Code:

#TR {It contains:} {#GAG}
#COND {(*).} {
  $Contents=%replace(%replace(%1, ", and ", "|"), ", ", "|")   
  $Contents=%countlist($Contents)
  #SUB {<color grey>You see~:</color>}
  #LOOPDB  $Contents {#IF (%val = 1) {#SHOW %key} {#SHOW %key ~(x%val~)}}
}


Much thanks from an old dead orc friend Rahab.
Reply with quote
Sutex-Kindred
Apprentice


Joined: 26 Aug 2009
Posts: 141

PostPosted: Fri May 20, 2011 5:11 am   
 
For other people, this takes input from a container and reorganizes it into a more eyeball friendly package. It is used when the data you are interested in begins on a new line, unlike some of the examples above which began on the same line.


Yes thanks
_________________
Entropy rules
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 Wolfpaw.net