Nyl Beginner
Joined: 07 Dec 2000 Posts: 13 Location: USA
|
Posted: Wed Jan 03, 2001 10:39 pm
Counting items in a container |
Those of you who play muds that count stuff for you can safely ignore this post. This alias/trigger combination tallies up all the unique items in a container and prints it in place of the normal display.
For instance, normally when I look in my saddlebag I see this:
Inside a saddlebag you see a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a rowan-oak potion, a rowan-oak potion, a rowan-oak potion, a gnarled knotwork etched shillelagh, a large mauve sack, a bezoar, a socra stone, a socra stone, a socra stone, a socra stone, a foul-smelling murky vial, a rowan-oak potion, a rowan-oak potion, a rowan-oak potion, a rowan-oak potion, a rowan-oak potion, a honey-ginseng elixir, a honey-ginseng elixir, a honey-ginseng elixir, a rowan-oak potion, a rowan-oak potion, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, a bottle of grey powder, and a bottle of grey powder.
As you can see, trying to figure out how many bottles of grey powder I have would be an impossible task, especially if the screen is scrolling. However, with my handy trigger, the previous output will instead look like this:
Inside the saddlebag you count...
61 x a bottle of grey powder
11 x a honey-ginseng elixir
10 x a rowan-oak potion
1 x a gnarled knotwork etched shillelagh
1 x a large mauve sack
1 x a bezoar
4 x a socra stone
And it only takes approximately half of one second to count all that junk!
And here is the script, alias first, trigger second:
Name:
clook (or whatever you want)
Value:
#T+ CountLook
look %-1
Pattern
^Inside the &container you see &itemlist$
ID:
CountLook
Value:
#GAG
#SHOW Inside the @container you count...
#VAR itemlist %replace( @itemlist, ", ", '|')
#VAR itemlist %replace( @itemlist, " and ", '|')
#VAR itemlist %replace( @itemlist, ".", "")
#VAR singlist %dups( @itemlist)
#FORALL @singlist {
#VAR count 0
#VAR check %i
#FORALL @itemlist {
#IF (%i = @check) {
#ADD count 1
#VAR itemlist %delitem( @check, @itemlist)
}
}
#SHOW @count x @check
}
#T- CountLook
To use this, simply type 'clook' followed by whatever you would normally put after a 'look' command. For instance, to look in my saddlebag, I type 'look in sadd'. So to count everything in my saddlebag, I type 'clook in sadd'.
A few notes about the script:
-It doesn't do any kind of sorting.
-It assumes your inventory is printed all on one line.
-It should work on any Simutronics mud with a minimum of tweaking. This was written using output from H&X.
-Make sure the trigger's ID is set to CountLook, and is disabled by default (unless you want to count everything).
Good luck, and happy counting!
-Nyl
Go Hokies! |
|