|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: 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...) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu May 08, 2008 12:31 am |
doh! I should have seen that.
What about the nesting? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Thu May 08, 2008 12:53 am |
Why would I use switch? The expressions aren't doing the same thing.... ?
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
|
|
|