  | 
	 
	
	
		LightBulb MASTER
 
  Joined: 28 Nov 2000 Posts: 4817 Location: USA
  | 
		
		  
			
			   Posted: Tue Nov 04, 2003 11:51 pm   
  Container Contents   | 
			 
			
				This seems to come up fairly often, so I decided to post my standard solution here.
 
#TR {Inside the (*) you see (*).} {#GAG;#VAR container {%1};#VAR contents {%2};#VAR contents %replace( {@contents}, ", and ", "|");#VAR contents %replace( {@contents}, ", ", "|");#VAR contents %countlist( @contents);ContentsSummary}
 
#AL ContentsSummary {#SAY Inside the @container you see;#LOOPDB @contents {#SAY %val %key}}
 
 
To create script, copy both lines to your command line (not the Settings Editor).
 
 
This works with MUD output similar to:
 
Inside the open large leather backpack you see a feathered birch spear, a feathered birch spear, a feathered birch spear, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, a quiver of oak arrows, and a quiver of oak arrows.
 
The output must all be on a single line, which can be a line wrapped by zMUD.
 
 
It converts it to a display similar to:
 
Inside the open large leather backpack you see
 
3 a feathered birch spear
 
22 a quiver of oak arrows | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		megamog75 Enchanter
  
  Joined: 20 Nov 2002 Posts: 627 Location: USA
  | 
		
		  
			
			   Posted: Mon Nov 17, 2003 10:29 pm      | 
			 
			
				#TRIGGER {^Inside the (*) you see (*).} {container={%1};contents={%2};#VAR contents %replace(%replace( {@contents}, ", and ", "|"), ", ", "|");contents=%countlist(@contents);#Sub {Inside the @container you see};#LOOPDB @contents {#say %val %key}}
 
 
Wouldn't this work the same and be a bit more compressed? | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		LightBulb MASTER
 
  Joined: 28 Nov 2000 Posts: 4817 Location: USA
  | 
		
		  
			
			   Posted: Mon Nov 17, 2003 11:06 pm      | 
			 
			
				There are many ways to do this. I could probably nest all the functions and get @contents with a single #VAR statement. I chose not to nest functions to make the script easier to understand.
 
 
The #LOOPDB should take significantly more time than any other portion of the script, so it doesn't really matter, timewise, whether the remaining statements are nested or not. | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		Talahaski Enchanter
 
  Joined: 10 Oct 2000 Posts: 656 Location: USA
  | 
		
		  
			
			   Posted: Mon Nov 17, 2003 11:15 pm      | 
			 
			
				Good Script Lightbulb, would you mind making one change to throw all the code into a class to keep it seperated.  I always have trouble writing scripts and specifying the class.  I forgot where to place the class name in some of the syntax, and I still have not figured out the . notation for variables within classes in case somebody has another variable by the same name.
  | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		LightBulb MASTER
 
  Joined: 28 Nov 2000 Posts: 4817 Location: USA
  | 
		
		  
			
			   Posted: Tue Nov 18, 2003 2:19 am      | 
			 
			
				If you want it in a separate class, just add a #CLASS command before the script and a #CLASS 0 at the end of it. If you want the variables to also be in that class, include the SETDEF option in the #CLASS command.
 
#CLASS Talahaski setdef
 
script goes here
 
#CLASS | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		Orang Apprentice
 
  Joined: 22 Jul 2004 Posts: 118 Location: USA
  | 
		
		  
			
			   Posted: Fri Jul 23, 2004 5:14 pm      | 
			 
			
				what i normally get when i look in my pack is:
 
 
l in pack
 
 
The interior of the pack has been soaked with oil.
 
The mining pack contains two gauntlets, an Armani suit, a charred set of rags, a globe of phosphorus, an angel's fishing
 
rod, a Wraith King's crown, a sacred silver broadsword, a flaming bract, a watery ring, a set of wyvern claws, a Klingon
 
hunting spear, an adamantine short sword, a steel right gauntlet, a knight's sword, an ancient monk's robe, two colourful
 
paintbrushes, two talismen of the shadows, a golden cord, a belt, two blood swords, four gleaming highwayman's knives, a
 
bottom section of a torn piece of parchment, a orange stone disc, a simple fiddle, a plain sword, a dragon seal, an
 
amulet of recovery, an accordion, a crimson blade, a lightning rod, a broadsword of a holy Paladin of Ilya, a small
 
picture of the Cathedral of Ilya , an amulet of Ilya , a pendant with the symbol of Ilya on it, a small icon of Ilya , a
 
fine longsword, two enchanted steel shields, a crystal-tipped spear, a Merlin's magic wand, a steel left gauntlet, a
 
talisman of inversion, a worn leather bound book, a mirror axe, a vial of dust, an infernal blade, an oaken staff, a
 
bloody ankh, a shield of a holy Paladin of Ilya, a red stone disc, a Z'Saracian pass card, two monk's sweeping staves, a
 
top portion of piece of parchment, and a dirk.
 
 
 
 
so tried to edit the script it would work for this and this is what i got:
 
 
	  | Code: | 
	 
	
	  #CLASS {ContainerContents}
 
#TR {Inside the (*) you see (*).} {#GAG;#VAR container {%1};#VAR contents {%2};#VAR contents %replace( {@contents}, ", and ", "|");#VAR contents %replace( {@contents}, ", ", "|");#VAR contents %countlist( @contents);ContentsSummary} {ContainerContents}
 
#AL ContentsSummary {#SAY Inside the @container you see;#LOOPDB @contents {#SAY %val %key}} {ContainerContents}
 
 | 
	 
 
 
 
and when i look in the pack this is what i get when i have the script installed:
 
The interior of the pack has been soaked with oil.
 
Inside the mining pack you see
 
1 two gauntlets
 
1 an Armani suit
 
rod, a sacred silver broadsword, a flaming bract, a watery ring, a dragon seal, a set of wyvern claws, a Klingon hunting
 
spear, an adamantine short sword, a steel right gauntlet, a knight's sword, an ancient monk's robe, two colourful
 
paintbrushes, two talismen of the shadows, a golden cord, a belt, two blood swords, a red stone disc, four gleaming
 
highwayman's knives, a top portion of piece of parchment, a orange stone disc, a simple fiddle, a plain sword, an amulet
 
of recovery, an accordion, a crimson blade, a lightning rod, a Wraith King's crown, a broadsword of a holy Paladin of
 
Ilya, a small picture of the Cathedral of Ilya , an amulet of Ilya , a pendant with the symbol of Ilya on it, a small
 
icon of Ilya , a fine longsword, two enchanted steel shields, a crystal-tipped spear, a Merlin's magic wand, a steel left
 
gauntlet, a talisman of inversion, a worn leather bound book, a mirror axe, a vial of dust, an infernal blade, an oaken
 
staff, a bloody ankh, a shield of a holy Paladin of Ilya, a Z'Saracian pass card, two monk's sweeping staves, a bottom
 
section of a torn piece of parchment, and a dirk.
 
1 a charred set of rags
 
1 a globe of phosphorus
 
1 an angel's fishing
 
 
 
 
i tried uninstalling it and reinstalling it and now all i get is the normal stuff that i should get without the script... a little help? | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		LightBulb MASTER
 
  Joined: 28 Nov 2000 Posts: 4817 Location: USA
  | 
		
		  
			
			   Posted: Fri Jul 23, 2004 10:38 pm      | 
			 
			
				
 
	  | LightBulb wrote: | 
	 
	
	  | The output must all be on a single line, which can be a line wrapped by zMUD. | 
	 
 
 
 
How much more explicit could I possibly be? The output must all be on one line for this script to work. Your output is not all on one line. This script will not work with your output!
 
 
This topic is for single-line contents. I won't complicate it with a script for multiline contents, which would necessarily be more complex. In addition, your example shows that your MUD has already counted and combined like items, so you don't even need this script. | 
			 
		  | 
	 
	
	  
		  
		    
			  _________________ LightBulb
 
Senior member
 
 
Most scripts in this forum are written for Command Line entry. 
 
Don't even open the Settings Editor unless its use is specified or obvious. | 
			       | 
			 
		   
		 | 
	 
	
		  | 
	 
	
		Oracle Apprentice
 
  Joined: 29 May 2002 Posts: 121
 
  | 
		
		  
			
			   Posted: Sat Nov 20, 2004 11:00 pm      | 
			 
			
				After reading this thread, I made something similiar to it where it takes several lines, puts them all into a string and then returns an itemized list.  Thanks Lightbulb for the original idea.
 
 
If you care to download the script, go to the following link.
 
 
http://infernalworlds.com.9.m6.net/smf/index.php?topic=1853.0 | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		Qaiia Wanderer
 
  Joined: 06 Apr 2007 Posts: 59
 
  | 
		
		  
			
			   Posted: Thu Jul 24, 2008 7:03 pm      | 
			 
			
				I took this and cleaned it up slightly, and changed the trigger a bit for GSIV.
 
 
 
	  | Code: | 
	 
	
	  #TRIGGER {^In the (*) you see (*).} {
 
  TempContainer={%1}
 
  TempContents={%2}
 
  #VAR TempContents %replace( %replace( {@TempContents}, ", and ", "|"), ", ", "|")
 
  TempContents=%countlist( @TempContents)
 
  #SUB {%ansi(grey)In the @TempContainer you see~:}
 
  #LOOPDB @TempContents {#IF (%val = 1) {#SHOW %key} {#SHOW %key ~(x%val~)}}
 
  } | 
	 
 
 
 
Output looks like this:
 
 
In the drawstring rucksack you see:
 
a talneo potion
 
some basal moss
 
some ephlox moss
 
some haphip root
 
some ambrominas leaf (x2)
 
a brostheras potion
 
some aloeas stem
 
some pothinir grass (x2)
 
a bright silvery flask
 
a blue crystal (x3)
 
a bolmara potion
 
a bur-clover potion (x2)
 
a wingstem potion (x2)
 
an intricate gold ring
 
a silvery potion (x2)
 
a tincture of haphip
 
an Ilvari luck charm
 
a glaesine crystal dragonfly
 
some wolifrew lichen
 
a garland of sovyn cloves
 
some acantha leaf
 
some calamia fruit
 
some cactacae spine
 
a rose-marrow potion
 
a pure potion (x42)
 
a silver-inlaid black locker manifest
 
a sparkling aquamarine potion
 
a pure potion and a silver-inlaid black leather bankbook | 
			 
		  | 
	 
	
	  | 
		  
		 | 
	 
	
		  | 
	 
	
		| 
		
		 | 
	 
	
		 | 
	 
 
  
	 
	    
	   | 
	
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
  | 
   
 
 |