|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: Sun Jul 13, 2003 10:03 pm
trigger help |
Here is my trigger:
Pattern: (%w) says 'replenish me'
Value : c replenish
#ADDITEM replens %1
#T- replenish
I want to make it so if the person's name who says "replensih me" is contained in a variable, lets call it, noreplen, then the trigger wont fire, otherwise it will |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Jul 13, 2003 11:15 pm |
This is done by using #IF and %ismember.
|
|
|
|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: Mon Jul 14, 2003 5:19 am |
#IF (%ismember( @noreplen)) {osay I'm sorry %1, But I cannot replenish you.} {
c replenish
#ADDITEM replens %1
#T- replenish
}
that's what the trigger looks like now but it doesnt work, even if the person's name is on the noreplen variable, it still replenishes... |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Jul 14, 2003 5:51 am |
Try:
#IF (%ismember(%lower(%1),%lower(@noreplen))) {osay I'm sorry %1, But I cannot replenish you.} {
c replenish
#ADDITEM replens %1
#T- replenish
} |
|
|
|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: Mon Jul 14, 2003 5:56 am |
thank you, it worked... but for the sake of my learning, can you explain what the %lower(%1),%lower(@noreplen) did?
|
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Mon Jul 14, 2003 6:18 am |
Syntax for ismember is:
Syntax: %ismember(s,list)
ie
quote:
#VAR friendsList {Zugg|Darker|Penny}
#VAR petitioner zyxcef
#IF (%ismember(@petitioner,@friendsList)) {cast heal @petitioner} {say Nope.}
I added the %lower to both pieces in case the check was case sensitive as I can't remember and didn't test. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Jul 14, 2003 6:22 am |
It's clear from your own example, %ismember( @noreplen), that you didn't even bother to look up %ismember. If you had, you'd have known it required TWO parameters, not just one. For the sake of your own learning, you should click on that menu at the top of zMUD which starts with the underlined H, find and read the entries for %ismember and %lower, then return here and explain for everyone else why Ton's script worked and yours didn't.
|
|
|
|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: Mon Jul 14, 2003 6:34 am |
i actually did (and i always look for help in the help files before i come here) , and i don't know what (s,list) means... i'm assuming list would be the variable containing the list of names, or a set of specified names. but i have no idea what "s" is (edit - upon further thought on the subject i have decided that s is the object which you are checking the list for, am i correct about this?)... and you don't need be sarcastic to get your point across
|
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Jul 14, 2003 6:57 am |
I'm sorry for the sarcasm. You are correct that "list" is the variable containing the list of names. You're also correct that "s" is the object (%1) you are checking the list for.
%lower is used to control the use of upper/lowercase so that you aren't trying to match LightBulb with LiGhTbUlB. %ismember is case sensitive, so those two would not match without using %upper, %lower, or %proper. In some cases it may be better to use the unmodified strings, so that LightBulb (a name) won't be matched with lightbulb (a device for creating illumination).
I hope this helped. Both this, and my last entry, were meant to be helpful. I apologize for the sarcasm, I should have just said use the Help menu. |
|
|
|
Latent Apprentice
Joined: 19 Aug 2002 Posts: 120 Location: USA
|
Posted: Mon Jul 14, 2003 7:03 am |
to be fair, had i thought about the usage of %ismember a little bit more I might have been able to figure it out, logically, if you want to test to see if something is in the list, you must specify what you want to check for...
|
|
|
|
|
|