|
mtuyooper Beginner
Joined: 24 Jul 2009 Posts: 14
|
Posted: 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 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
mtuyooper Beginner
Joined: 24 Jul 2009 Posts: 14
|
Posted: 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! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
mtuyooper Beginner
Joined: 24 Jul 2009 Posts: 14
|
Posted: 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] |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: 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...
|
|
|
|
mtuyooper Beginner
Joined: 24 Jul 2009 Posts: 14
|
Posted: 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! |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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~)}}
}
|
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
mtuyooper Beginner
Joined: 24 Jul 2009 Posts: 14
|
Posted: 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! |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Wed May 18, 2011 4:52 pm |
%params and %1 should be the same for a given pattern of {(*).} no?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
|
mtuyooper Beginner
Joined: 24 Jul 2009 Posts: 14
|
Posted: 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. |
|
|
|
Sutex-Kindred Apprentice
Joined: 26 Aug 2009 Posts: 141
|
Posted: 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 |
|
|
|
|
|