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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu May 22, 2008 3:04 pm   

Trigger Not Firing on one Condition
 
Code:

#TRIGGER thirsty {^You are thirsty.$}
{
 #SWITCH (@posn)
  (("wake") OR ("rest")) {#5 {#send "drink decan"}}
  ("sleep") { #send rest;#5 {#send "drink decan"};#send {sleep}}
} {General Triggers}


Is the code, at first it was working for "sleep" and "wake" but now it doesn't seem to work for any of them, "rest" never worked.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu May 22, 2008 3:11 pm   
 
Because your #switch syntax is invalid. I'm sure I remember telling you this before. You can only use the alternative #switch syntax for simple something=something comparisons. Anything else and you'll need to use the full syntax.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu May 22, 2008 3:24 pm   
 
I'm confused. The title of this thread is "Trigger not firing on one condition". Is the trigger firing or not? Whether the trigger fires has nothing to do with @posn. It is only after the trigger actually fires that it looks at @posn. So the first question is: is the trigger firing?

I believe that the (("wake") OR ("rest")) does not work. I think the shortcut is intended to only test a single value, and you are trying to test two. There are two solutions:
Code:
#TRIGGER thirsty {^You are thirsty.$}
{
 #SWITCH (@posn)
  ("wake") {#5 {#send "drink decan"}}
  ("rest") {#5 {#send "drink decan"}}
  ("sleep") { #send rest;#5 {#send "drink decan"};#send {sleep}}
} {General Triggers}

or:
Code:
#TRIGGER thirsty {^You are thirsty.$}
{
 #SWITCH ((@posn = "wake") OR (@posn = "rest")) {#5 {#send "drink decan"}}
  (@posn = "sleep") { #send rest;#5 {#send "drink decan"};#send {sleep}}
} {General Triggers}

The last time you tried to put two tests in a switch shortcut, people tried to get you not to.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu May 22, 2008 5:24 pm   
 
Right, but at that time it was two different variables. I was under the assumption that you could have multiple comparisons of the same variable.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Dumas
Enchanter


Joined: 11 Feb 2003
Posts: 511
Location: USA

PostPosted: Thu May 22, 2008 8:07 pm   
 
Nope. Each line of the switch is basically an OR statement anyways.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu May 22, 2008 9:10 pm   
 
chamenas wrote:
Right, but at that time it was two different variables. I was under the assumption that you could have multiple comparisons of the same variable.

You can, but only with the full syntax. Think of the alternative syntax as a shortcut for the very common operation where you're trying to compare different values of the same variable. The only thing the alternative syntax can do is =. It basically concats the first part, an =, and the second part and then treats the result as an expression. Since @posn="rest" or "wake" isn't a valid expression, your syntax is wrong.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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