|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 9:14 pm
Trying to debug, failing |
I looked hard at this code and I just can't figure out why it is giving me an "unmatched braces" error.
Code: |
#REGEX {^TICK IN 5 SECONDS.$} {#IF ((@regen=1) AND (@posn="rest")) {sleep @bed} {@regen=0} } {General Triggers}
|
I'm sure one of you will find it quickly, but it's not as if I didn't spend a half an hour trying to figure it out. Why am I getting that error? How can I fix it? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun May 18, 2008 9:36 pm |
@regen=0
should be:
regen=0.
Syntax editor would have pointed you in the right direction. I've told you before, post it in Editor or syntax editor, hit Ctrl+K with the editor panel active, and it'll pretty much point out your problem.
Charneus |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 9:38 pm |
*sighs* Alright, I must have missed it when you said it.
So
ctrl+shift+enter and then ctrl+k ? |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun May 18, 2008 9:43 pm |
Heh. You could do it that way, yes. Just paste the invalid code, and when you hit Ctrl+K, it'll move your cursor to the area that the mistake is in. In this instance, it moved it to:
@regen|=0
with the | being the cursor. From there, it's a bit easier to tell what the problem is, and you probably would have caught it.
Charneus |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 10:23 pm |
well, while I have you (hopefully)
I've never tried a double variable switch, it wants a command list so I know I'm initializing it wrong:
Code: |
#wait 400
#say Loading Regen Sleep Trigger...
#REGEX Tick_Regen {^TICK IN 5 SECONDS.$} {#SWITCH ((@regen) AND (@posn))
((1) AND ("rest")) {sleep @bed}
((1) AND ("wake")) {regen=0;#say Regen: @Regen} }
((1) AND ("sleep")) {regen=0;#say Regen: @Regen} } {General Triggers}
|
I just don't know what is supposed to be right. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sun May 18, 2008 10:39 pm |
...
Code: |
#if (@regen) {
#switch (@posn)
("rest") {sleep @bed}
("wake") {regen=0}
("sleep") {regen=0}
}
|
Why are you doing #say Regen: @Regen? That's just going to show 1 or 0, unless you have two Regen variables in which case will cause problems. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 10:52 pm |
I'm doing say so that I know it's being turned off. The #if and #switch is the best way to go then? shouldn't it be @regen=1?
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sun May 18, 2008 11:17 pm |
I guess if you want it to be.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sun May 18, 2008 11:17 pm |
I'm confused.
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Sun May 18, 2008 11:44 pm |
Code: |
{#SWITCH ((@regen) AND (@posn))
((1) AND ("rest")) {sleep @bed}
((1) AND ("wake")) {regen=0;#say Regen: @Regen} }
((1) AND ("sleep")) {regen=0;#say Regen: @Regen} } {General Triggers} |
is all wrong.
Read the documentation on SWITCH. Then change your code to this:
Code: |
{#SWITCH (@regen AND @posn="rest") {sleep bed} (@regen AND @posn="wake") {regen=0;#say Regen: @regen} (@regen AND @posn="sleep") {regen=0;#say Regen: @regen}} {General Triggers} |
That should work for you.
Charneus |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon May 19, 2008 12:00 am |
But, like oldguy said, there's no reason to test regen each time if you test it once at the start.
In the expression, it can be @regen=1 if you want. However, since 1 evaluates to true and 0 evaluates to false, just putting @regen in the expression will do. When @regen has a value of 1, the value is true; when it's 0, it's false. |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 19, 2008 12:23 am |
Right, so CMUD automatically assumes that?
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon May 19, 2008 1:42 am |
Assumes what? You are making stuff hard again that doesn't need to be. Just paste what I showed above it will work fine. Oh and read what Fang said again.
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Mon May 19, 2008 1:44 am |
I will, I just want to understand it. CMUD automatically assumes values of 1 and 0 to be true/false statements, I didn't know that. But yes, I know 1 and 0 is true and false.
|
|
|
|
|
|