|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: 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. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: 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.
|
|
|
|
Dumas Enchanter
Joined: 11 Feb 2003 Posts: 511 Location: USA
|
Posted: Thu May 22, 2008 8:07 pm |
Nope. Each line of the switch is basically an OR statement anyways.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
|
|
|