|
talith Novice
Joined: 03 Mar 2005 Posts: 31
|
Posted: Sat Jun 16, 2012 12:06 am
Forall with string lists |
Greetings.
I'm attempting to create a simple trigger that fires for every line received and checks %line (the last line received from the mud) against a string list I have. The goal is to fire whenever it receives a line that is NOT in my string list. This sounds simple to me to do and yet I'm having trouble.
Code: |
#forall @testlist {#if (%line != %i) {#beep} {}} |
is the simplest I think it can be done, but for whatever reason it does not seem to work.
Is there a way to better do this, or make the above code work? It really seems to me that it should be simple but I'm stumped on it, any help would be appreciated. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Jun 16, 2012 1:18 am |
try using a trigger instead:
#TR {*} {#IF (%ismember(%line, @testlist)) {#BEEP}} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sat Jun 16, 2012 3:57 am |
Shalimar's code will check if the line IS in the string list. If you want to check if it's not, you need to negate the condition, like this:
Code: |
#TR {*} {#IF (!%ismember(%line, @testlist)) {#BEEP}} |
|
|
|
|
talith Novice
Joined: 03 Mar 2005 Posts: 31
|
Posted: Sat Jun 16, 2012 7:42 am |
Perfect, the above code works just like I wanted. I do have an additional question though. If I have a value in the string list such as @testvalue, and the mud sends the text "@testvalue", it doesn't seem to think the text is in the string list. Is there a way to make it see the @ correctly and trigger?
And lastly, is there a way to have a trigger completely ignore user input and not fire on it?
Thanks for the help! |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sat Jun 16, 2012 7:51 am |
You mean not expanding the @ as a variable reference? Putting it in quotes should do the trick. And I'm not sure what you mean by your last question... do you mean the command echoes when you type something? Triggers don't fire on those, as far as I know...
|
|
|
|
talith Novice
Joined: 03 Mar 2005 Posts: 31
|
Posted: Sat Jun 16, 2012 11:27 am |
Ok I'll try to explain better.
Here is the trigger.
Code: |
#TRIGGER {(*)} {
#IF (%ismember( %line, @linelist)) {} {
#say {Adding %line to linelist!}
#additem linelist %line
}
} |
Pretty simple, it reads each line it receives and if it has not been added to the the list, it adds it. No problems there.
The problem arises when linelist looks like
Code: |
#VAR linelist {walk @109|You begin to walk} |
You see, walk @109 is the command I send to the mud, but this trigger fires when I send the command which is not necessarily a problem in itself. The problem arises when I send the command again, the trigger acts as if it is not already added to the list, and tries to add it again. My question is is there a way to make it see the "walk @109" and correctly recognize that it is in the list and not fire. Or if there is a way that the trigger will ignore input completely?
Ideally I would like an answer to both questions, but anything would be helpful.
I hope that cleared things up, thanks. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Jun 16, 2012 12:03 pm |
you could turn off the command echo
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|