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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
genie
Newbie


Joined: 07 Sep 2002
Posts: 9
Location: Yemen

PostPosted: Thu Nov 14, 2002 1:44 am   

removing string from variable
 
Whenever I kill something/someone I want a certain string value to be removed from a variable. I store all my targets into a variable for example mom|dad|brother
then I execute my kill alias on the variable.
Whenever I kill someone I want the target to be removed from the variable.

So Far ive come up with

pattern: You killed (*)

trigger: #if %ismember( @target_list) {
#var target_list %delitem( %1, @target_list)
}

But that isnt working as you might have guessed :)


If all you have is duct tape, everything starts to look like a duct.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Nov 14, 2002 3:14 am   
 
Syntax for %ismember is:
%ismember(s,list)

So the #IF should be:
#IF (%ismember("%1", @target_list)) {#VAR target_list %delitem("%1", @target_list)}

I also added double quotes around the %1's in case it contains a comma or something else that might affect the function call.

Kjata
Reply with quote
genie
Newbie


Joined: 07 Sep 2002
Posts: 9
Location: Yemen

PostPosted: Sat Nov 16, 2002 2:47 am   
 
Hello Kjata, Thanks for the help.
It worked perfectly.
One thing I noticed tho that it only works on the first string in the variable ?

If the target list looked something like neil|bob and I kill bob first the string isnt removed ? (example: neil isnt present in the room and I use my alias to be executed on each string in the variable therefor bob being the killed first)

Thanks again

If all you have is duct tape, everything starts to look like a duct.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Nov 16, 2002 4:30 am   
 
Actually, you could skip the #IF. If your victim isn't on the list when you try to remove it, nothing will happen. If you don't allow duplicates in your list, you can just use #DELITEM. If you do allow duplicates, use %delitem. So the trigger Value becomes one of these two:
#DELITEM target_list {%1}
#VAR target_list {%delitem({%1}, @target_list)}

LightBulb
Senior Member
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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