|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 8:17 am
String list and IFs |
I am having trouble trying to get this trigger to generate a different if {true} {false} command based on which element in a string list it matches with.
#VAR chats {gangpaths|telepaths|broadcasts}
#TRIGGER {%1 ({@chats}): "(%3)"} {#IF...
I had separate triggers for the channels before but I thought I would try it in one. I also have a friends variable that it checks %ismember of before doing %3 but I would like to respond to failures based on what chat channel is used.
If @chat = gangpaths %ismember... {%3} {gangpath -Command Failed-}
Any help thanks. |
|
|
|
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Fri Nov 06, 2009 9:16 am |
first of all dont use %1 or %3 in the trigger pattern i know its not good but i always use (*)
if that does not work can you post what a couple of the chat channels look like? |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 9:40 am |
I could change it to (%w) ({chats}): "(%*)"
but it doesn't seem to matter.
Bob gangpaths: "hi"
Bob telepaths: "hi"
Bob broadcasts: "hi"
They're pretty basic. |
|
|
|
hadar Apprentice
Joined: 30 Aug 2009 Posts: 198 Location: my apt, in california
|
Posted: Fri Nov 06, 2009 10:12 am |
(*) (@chats): ~"(*)~" ... imho thats mysetup for a trigger
then the if function would be
#if (%2=channelname) {true} {false} |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Nov 06, 2009 2:51 pm |
Hadar is correct in that you don't use %#s in trigger patterns. They were considered a bug in zMUD, and you'll run into all sorts of trouble.
Also, it looks like you're wanting to execute the %3 if the trigger meets certain criteria. When doing this, you NEED to preface it with #EXEC. Functions (whether they start with % or @) cannot begin a line.
This was a change in CMUD from zMUD.
Therefore, your trigger pattern would look something like this:
Code: |
#TRIGGER {(%w) ({@chats}): (*)} {#IF (%2="gangpaths" AND %ismember(%1, @whateverlist)) {#EXEC %3} {gangpath -Command failed-}}
|
Charneus |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 5:56 pm |
If I make multiple IFs like that the false state for the first IF would always go off because %2 would not be the chat channel used.
The only criteria %3 has to meet is that it is said by someone on the string list. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Nov 06, 2009 6:32 pm |
Then simply change it to:
#IF (%2="gangpaths") {#IF (%ismember(%1, @friendlist)) {#EXEC %3} {gangpath -Command failed-}}
Charneus |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 7:03 pm |
#TRIGGER {(%w) ({@chats}): "(*)"}
#IF (%2="gangpaths") {#IF (%ismember(%1, @friends)) {#EXEC %3) {gb -Command Failed-}}} {#IF (%2="telepaths") {#IF (%ismember(1, @friends)) {#EXEC %3} {reply -Command Failed-}}} {#IF (%2="broadcasts") {#IF (%ismember(1, @friends)) {#EXEC %3} {br -Command Failed-}}} |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Nov 06, 2009 7:22 pm |
Before each #IF (%2, remove the { and replace it with a ;.
It will never work the way you have it right now.
Therefore, it'll look like this:
Code: |
#IF (%2="gangbangs") {#IF (%ismember... {gb -Command failed-};#IF (%2="telepaths" ... |
Charneus |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 7:43 pm |
#IF (%2="gangpaths") {#IF (%ismember(%1, @friends)) {#EXEC %3) {gb -Command Failed-};{#IF (%2="telepaths") {#IF (%ismember(1, @friends)) {#EXEC %3} {reply -Command Failed-};{#IF (%2="broadcasts") {#IF (%ismember(1, @friends)) {#EXEC %3} {br -Command Failed-}}}}}}}
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Nov 06, 2009 7:52 pm |
I said replace the {, not put a ; and a {. :p
I'd copy/paste, but on blackberry right now.
#IF (%2="gangpaths} {gangpaths stuff only};#IF (second channel)etc.
Charneus |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 8:32 pm |
#IF (%2="gangpaths") {#IF (%ismember(%1, @friends)) {#EXEC %3) {gb -Command Failed-};#IF (%2="telepaths") {#IF (%ismember(1, @friends)) {#EXEC %3} {reply -Command Failed-};#IF (%2="broadcasts") {#IF (%ismember(1, @friends)) {#EXEC %3} {br -Command Failed-}}}}}
Ya I had tried it like that. I tried removing the ; and using new lines but it still doesn't work. It neither replies nor executes %3 so I am running out of ideas. |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Fri Nov 06, 2009 9:00 pm |
Ok. One last time. Copy/paste the below (and I'm simplifying it for you):
Code: |
#TRIGGER {(%w) ({@chats}): ~"(*)~"} {#SWITCH (%2) ("gangpaths") {$ChatCmd="gb"} ("broadcasts") {$ChatCmd="br"} ("telepaths") {$ChatCmd="reply"};#IF (%ismember(%2, "gangpaths|broadcasts|telepaths")) {#IF (%ismember(%1, @friends)) {#EXEC %3} {#SEND $ChatCmd "-Command failed-"}}} |
That's how I would have done the whole thing to begin with. Let me know how it works for you.
Charneus |
|
|
|
AmongTheDecay Beginner
Joined: 25 Apr 2009 Posts: 28
|
Posted: Fri Nov 06, 2009 9:35 pm |
That gave a compiling error from an invalid local variable. I added a first line of $ChatCmd="" and it works. Thanks a bunch.
|
|
|
|
|
|