|
shaun.murray Magician
Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Wed Jul 30, 2008 7:14 pm
working with stringlist (should be easy for ya'll... hehe) |
I am adding a keyword to a stringlist every time I get a certain item. Then, when my inventory is full, I clean out my inventory based on whats in that stringlist. But, I'm having a little bit of a syntax issue with the removing items from the stringlist when it fires.
Code: |
#trig {^You get a shirt.$} {#additem junk_eq shirt}
#trig {^You get a rusty knife.$} {#additem junk_eq knife}
#trig {^You get a pink ribbon.$} {#additem junk_eq ribbon} |
Basically if all of them fire, the variable looks like this:
Code: |
#variable jun_eq {shirt|knife|ribbon} |
And to get rid of everything when inventory is full:
Code: |
#trig {^Your inventory is full.$} {#loop %numitems(@junk_eq) {drop all.@junk_eq;%delitem(1,@junk_eq)}} |
But, the output seems to be:
drop all.shirt|ribbon|knife
shirt|ribbon|knife
drop all.shirt|ribbon|knife
shirt|ribbon|knife
drop all.shirt|ribbon|knife
shirt|ribbon|knife |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Jul 30, 2008 7:50 pm |
It's doing what you are telling it to do. In your last bit of code, instead of @junkitems, you want something like @junkitems.%i. But another way to do it is:
Code: |
#trig {^Your inventory is full.$} {#forall @junk_eq {drop all.%i;%delitem(1,%i)}}
|
|
|
|
|
shaun.murray Magician
Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Wed Jul 30, 2008 7:56 pm |
Hrmm... So why would I get this?
drop all.shirt
shirt
drop all.ribbon
ribbon
drop all.knife
knife
It seems that %delitem(1,%1) is displaying the item its deleting? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jul 30, 2008 8:02 pm |
The problem is with the %delitem...that is a *function* that returns a result (which is then getting displayed and sent to the MUD). It returns a new string list with the item removed. You are confusing the %delitem *function* with the #DELITEM *command*. Using #DELITEM will remove the item from the string list rather than just returning a new list. So you should be using:
#DELITEM junk_eq %i
(also, I think you meant %delnitem and not %delitem since you were trying to delete the first item in a list) |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Wed Jul 30, 2008 8:02 pm |
Well you beat me. I was going to say about the same thing.
#REGEX {^You get a (?:rusty |pink )?(shirt|knife|ribbon)\.$} {#additem junk_eq %1}
To drop:
#REGEX {^Your inventory is full\.$} {#forall @junk_eq {drop all.%i;#delitem junk_eq %i}} |
|
|
|
shaun.murray Magician
Joined: 23 Jul 2005 Posts: 334 Location: Chicago
|
Posted: Wed Jul 30, 2008 8:13 pm |
ah... yes yes yes, thank you all! =D
|
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Thu Jul 31, 2008 8:39 am |
I'd probably have gone with something along the lines of:
#LOOP %numitems(@junk_eq) {drop all.%pop(@junk_eq)}
Not that it matters, of course. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
|
|