 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 12:02 am
Illegal Character in Expression |
Simple trigger really...
You are thirsty.
drink decan
drink decan
drink decan
drink decan
drink decan
But, as one cannot drink while asleep... it gets slightly more complex. Thus, I have the variable posn, which can either equal wake or sleep.
| Code: |
| #IF (posn=wake){drink decan;drink decan;drink decan;drink decan;drink decan}{rest;drink decan;drink decan;drink decan;drink decan;drink decan;sleep} |
But with that in the comman box, I get:
| Quote: |
Error compiling script:
illegal character in expression: {
|
|
|
|
|
 |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Thu Mar 27, 2008 12:11 am |
Try it this way:
| Code: |
#IF (posn=wake) {drink decan;drink decan;drink decan;drink decan;drink decan} {rest;drink decan;drink decan;drink decan;drink decan;drink decan;sleep}
|
Blanks are required between the fields of the #IF command. So:
#IF (condition) {true-condition-command(s)} {false-condition-command(s)} |
|
_________________ Sic itur ad astra. |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 12:17 am |
It worked, thanks.
|
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Thu Mar 27, 2008 12:45 am |
This should always evaluate to false:
Perhaps you meant
| Code: |
| #IF (@posn="wake") {drink decan;drink decan;drink decan;drink decan;drink decan} {rest;drink decan;drink decan;drink decan;drink decan;drink decan;sleep} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 12:59 am |
Well it worked the way I had it...
|
|
|
|
 |
Larkin Wizard

Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Thu Mar 27, 2008 2:28 am |
Doubtful. 
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 2:32 am |
Yeah, it just had the appearance of working. It did with his suggestion 
|
|
|
|
 |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Thu Mar 27, 2008 4:20 am |
Actually, I agree with Larkin. My remedy just took care of the syntax problem. I didn't go into what I thought about the code, but I didn't think it would work the way you stated it.
|
|
_________________ Sic itur ad astra. |
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 8:51 am |
| Anaristos wrote: |
| Actually, I agree with Larkin. My remedy just took care of the syntax problem. I didn't go into what I thought about the code, but I didn't think it would work the way you stated it. |
Hence the post right above yours. |
|
|
|
 |
Larkin Wizard

Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Thu Mar 27, 2008 11:56 am |
Since no one else has clarified this yet, I'll let you know that the cause of your original error message was that you didn't include spaces between the close-open parentheses/brackets. When you end one "block" you need a space before you begin the next.
Bad:
| Code: |
| #IF (@blah){code}{more code} |
Good:
| Code: |
| #IF (@blah) {code} {more code} |
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 12:08 pm |
| Anaristos wrote: |
Try it this way:
| Code: |
#IF (posn=wake) {drink decan;drink decan;drink decan;drink decan;drink decan} {rest;drink decan;drink decan;drink decan;drink decan;drink decan;sleep}
|
Blanks are required between the fields of the #IF command. So:
#IF (condition) {true-condition-command(s)} {false-condition-command(s)} |
|
|
|
|
 |
Larkin Wizard

Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Thu Mar 27, 2008 1:24 pm |
Yeah, my bad. 
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 1:25 pm |
Well, at least you guys know what you're talking about. 
|
|
|
|
 |
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Thu Mar 27, 2008 3:23 pm |
It's a lot easier to just write it as:
| Code: |
#IF (@posn="wake") {
#5 {#send "drink decan"}
} {
#send rest
#5 {#send "drink decan"}
#send sleep
} |
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 4:12 pm |
the #5 sends it 5 times?
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 27, 2008 4:17 pm |
Yep.
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 4:24 pm |
| Quote: |
Error compiling script:
command expected
|
| Code: |
Pattern:
^You are thirsty.$
Command:
##IF (@posn="wake") {
#5 {#send "drink decan"}
} {
#send rest
#5 {#send "drink decan"}
#send sleep
}
|
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Mar 27, 2008 4:37 pm |
You typoed, there's an extra # before your #if command.
|
|
|
|
 |
chamenas Wizard

Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu Mar 27, 2008 4:56 pm |
| Fang Xianfu wrote: |
| You typoed, there's an extra # before your #if command. |
And that's why I stopped programming oh so long ago :P |
|
|
|
 |
|
|
|