|
genie Newbie
Joined: 07 Sep 2002 Posts: 9 Location: Yemen
|
Posted: 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. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: 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 |
|
|
|
genie Newbie
Joined: 07 Sep 2002 Posts: 9 Location: Yemen
|
Posted: 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. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: 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 |
|
|
|
|
|