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 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: {
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 27, 2008 12:17 am   
 
It worked, thanks.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Thu Mar 27, 2008 12:45 am   
 
This should always evaluate to false:
Quote:
#IF (posn=wake)
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
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 27, 2008 12:59 am   
 
Well it worked the way I had it...
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Mar 27, 2008 2:28 am   
 
Doubtful. Neutral
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 27, 2008 2:32 am   
 
Yeah, it just had the appearance of working. It did with his suggestion Razz
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

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


Joined: 26 Mar 2008
Posts: 1547

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


Joined: 25 Mar 2003
Posts: 1113
Location: USA

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


Joined: 26 Mar 2008
Posts: 1547

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


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Thu Mar 27, 2008 1:24 pm   
 
Yeah, my bad. Razz
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 27, 2008 1:25 pm   
 
Well, at least you guys know what you're talking about. Wink
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Mar 27, 2008 4:12 pm   
 
the #5 sends it 5 times?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Mar 27, 2008 4:17 pm   
 
Yep.
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: 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
  }
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Mar 27, 2008 4:37 pm   
 
You typoed, there's an extra # before your #if command.
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: 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
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