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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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.
Reply with quote
hadar
Apprentice


Joined: 30 Aug 2009
Posts: 198
Location: my apt, in california

PostPosted: 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?
Reply with quote
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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.
Reply with quote
hadar
Apprentice


Joined: 30 Aug 2009
Posts: 198
Location: my apt, in california

PostPosted: 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}
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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
Reply with quote
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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
Reply with quote
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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-}}}
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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
Reply with quote
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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-}}}}}}}
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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
Reply with quote
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: 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
Reply with quote
AmongTheDecay
Beginner


Joined: 25 Apr 2009
Posts: 28

PostPosted: 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.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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