Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: 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
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: 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)}}
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: 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?
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: 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}}
Reply with quote
shaun.murray
Magician


Joined: 23 Jul 2005
Posts: 334
Location: Chicago

PostPosted: Wed Jul 30, 2008 8:13 pm   
 
ah... yes yes yes, thank you all! =D
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net