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 08, 2008 12:19 am   

Unmatched Braces
 
I love this wonderful error.

Code:

#regex current_board {^You begin to mill a (\w+) log.$} {
current_board=%1
#if (@crafting="off") {
crafting="on"
@craftinginitial=1
}
#if (@craftinginitial=1) {
#say Crafting: @crafting
craftinginitial=0
} } {General Triggers|Crafting}


Can any of you wonderful people see why it's giving me this unmatched braces error?

here I've nested it for ease of viewing:
Code:

#regex current_board {^You begin to mill a (\w+) log.$}
{
  current_board=%1
  #if (@crafting="off")
    {
      crafting="on"
      @craftinginitial=1
    }
  #if (@craftinginitial=1)
    {
      #say Crafting: @crafting
      craftinginitial=0
    }
} {General Triggers|Crafting}


(granted it being fixed, should this nested version work? I'd prefer to have all of my stuff nested...)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Thu May 08, 2008 12:28 am   
 
@craftinginitial=1
are you trying to doo an indirect variable assignment there?

and shouldn't the trigger name be in quotes?
_________________
Discord: Shalimarwildcat
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu May 08, 2008 12:29 am   
 
Your error comes from this:

#if (@crafting="off")
{
crafting="on"
@craftinginitial=1
}

If you are setting the variable "craftinginitial" to 1, then you need to rid it of the @ in front of it. Much like you have "crafting="on"" set. If "craftinginitial" contains a word that you're setting as the variable, then you should probably use #var @craftinginitial 1 instead.

Charneus

By the way, easiest way to detect errors yourself is to post them in the Editor window or in the Package Editor window. I've found MANY mistakes that were easy to fix by doing so, and using "Ctrl+K" (or go to Editor->Check Syntax), it'll tell you EXACTLY where the error lies, and you can get a better idea of what's wrong with it.


Last edited by charneus on Thu May 08, 2008 12:31 am; edited 1 time in total
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu May 08, 2008 12:31 am   
 
doh! I should have seen that.

What about the nesting?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu May 08, 2008 12:37 am   
 
The nesting should be ok. Don't see why not. But why aren't you using SWITCH for this?

current_board=%1
#SWITCH (@crafting="off") {crafting="on";craftinginitial=1} (@craftinginitial=1) {#say Crafting: @crafting;craftinginitial=0}} {General Triggers|Crafting}

Probably easier, too. *shrug*

Charneus
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu May 08, 2008 12:53 am   
 
Why would I use switch? The expressions aren't doing the same thing.... ?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu May 08, 2008 2:11 am   
 
The expressions don't need to do the same thing. Read up on the help file regarding it.

Charneus
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu May 08, 2008 9:17 am   
 
Actually, that switch will produce a slightly different result. The second if statement will run after the first one in the above example, whereas in the switch example, only one of them will ever be run each time the alias is executed.
_________________
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