|
Dravon Beginner
Joined: 05 Jan 2002 Posts: 29 Location: USA
|
Posted: Wed Jun 04, 2003 12:07 am
Trigger help for version 6.62 public |
I am trying to make a trigger that when i look inside a container it will combine all the like items and give me the number of them. I see this when I look inside a container.
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.
what I would like to see is
Inside the open large leather backpack you see
3 feathered birch spear
22 quiver of oak arrows
I am trying to cut down on the clutter shown in my screen when I look into containers and such. Thanks for any help you can give me.
Gary |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Jun 04, 2003 1:31 am |
quote:
I am trying to make a trigger that when i look inside a container it will combine all the like items and give me the number of them. I see this when I look inside a container.
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.
what I would like to see is
Inside the open large leather backpack you see
3 feathered birch spear
22 quiver of oak arrows
I am trying to cut down on the clutter shown in my screen when I look into containers and such. Thanks for any help you can give me.
Gary
If you search the general forum, you'll probably find the script from way back when. To recap, however, create a trigger that matches the In this container line:
#trigger {^Inside the open (*) you see (*).$} {}
the meat of the code goes a little something like this:
#if (%pos(",","%2") {#noop comma-delimited;#forall %replace(%replace("%2"," and "," "),", ","|") {#if (%iskey(@ContainerItems,%i)) {#noop duplicate item found;#add ContainerItems.%i 1} {#noop new item;#addkey ContainerItems %i 1}}} {#noop less than 3 items, no commas;#forall %replace("%2"," and ","|") {#if (%iskey(@ContainerItems,%i)) {#noop duplicate item found;#add ContainerItems.%i 1} {#noop new item;#addkey ContainerItems %i 1}}}
It's untested and there might be some issues to work out regarding valid key names, but it should only run through the original list of items one time. Every time it finds a duplicate item, it increments a datarecord key by 1. Every time it finds a new item, it creates a datarecord key and sets it to 1.
You'll then want to display your work, so you'll need something like this:
#sub {Inside the %1 you see}
#loopdb @ContainerItems {#say " "%val" x "%key}
This should provide output similar to what you want, except that the item listing is indented three spaces.
li'l shmoe of Dragon's Gate MUD |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Jun 04, 2003 1:38 am |
Check your MUD first. It's likely to have a setting to combine like items in containers, your inventory, on the ground, etc. If it does, that will be far easier than writing a script.
If not, much will depend on whether the contents are all on a single line, wrapped by zMUD or on multiple lines, wrapped by the MUD. If it's wrapped by the MUD, it will also be important whether spaces at the ends of lines are preserved.
The general method would be to capture everything between
Inside the open large leather backpack you see
and the following period to the same variable, concatenating and adding spaces (if needed) if multiple lines are sent from the MUD.
#VAR contents {%1}
#VAR contents {@{contents}%1}
#VAR contents {@contents %1}
After capturing it all to the same variable, convert the variable to a list by replacing all commas and the space immediately following them with pipes
#VAR contents %replace( {@contents}, ", ", "|")
You can then use the countlist function to count the items and convert them to a record-variable
#VAR contents %countlist( @contents)
This can then be displayed using any method you find convenient, such as %db or %expanddb
#SAY %expanddb( @contents, %crlf, " : ")
LightBulb
Advanced Member |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Wed Jun 04, 2003 1:50 am |
Nope, he's from Dragon's Gate MUD. We support only two features--input and output. No colors, no extension protocols, and none of the handy-dandy features most newer muds have.
I did forget about %countlist(), though.
li'l shmoe of Dragon's Gate MUD |
|
|
|
Dravon Beginner
Joined: 05 Jan 2002 Posts: 29 Location: USA
|
Posted: Wed Jun 04, 2003 3:49 am |
I found this one but it doesnt work I tried the other 2 cant get them to work either could you do a copy and paste so I can do that thanks.
#TRIGGER {Inside the open large leather backpack you see &itemlist$} {#SUB {Inside the open large leather backpack you see~:};#VAR itemlist %replace( @itemlist, ", and ", "|");#VAR itemlist %replace( @itemlist, ", ", '|');#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)}};#VAR check %replace( @check, "a ", "");#VAR check %replace( @check, "an ", "");#VAR check %replace( @check, "some ", "");#SHOW @count @check}}
Gary |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Wed Jun 04, 2003 4:26 am |
Assuming (since both you and Matt used one-line triggers) that it's all one line:
#TR {Inside the open (*) you see (*).} {#VAR container {%1};#VAR contents {%2};#VAR contents %replace( {@contents}, ", ", "|");#VAR contents %countlist( @contents);ContentsSummary}
#AL ContentsSummary {#SAY Inside the open @container you see;#LOOPDB @contents {#SAY %val %key}}
NOTES: The #VAR commands could all be combined, but it's easier to understand using only one function at a time. As you can see, all I did was follow the outline I gave above.
When tested, it gave:
Inside the open large leather backpack you see
3 a feathered birch spear
21 a quiver of oak arrows
1 and a quiver of oak arrows
I'll leave it for you to figure out how to remove the "and". You'll probably want to add a #GAG command also.
LightBulb
Advanced Member |
|
|
|
Dravon Beginner
Joined: 05 Jan 2002 Posts: 29 Location: USA
|
Posted: Wed Jun 04, 2003 9:17 pm |
thanks alot I think I understand that one. Ill have to try and do some different stuff with it. Thanks again
Gary |
|
|
|
|
|
|
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
|
|