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: Wed Apr 23, 2008 4:56 pm   

Unmatched Braces
 
Code:

#regex movement {^I see no(?: \w+)? log here.$} {
if (@loading="off") {
#6 {#send "drag all.@current_board n" }
drag all.@current_board e
drag all.@current_board s
drag all.@current_boardw
drag all.@current_board d }
{ loading="off" } } {General Triggers|Crafting}


*sighs* I've learned a lot from you guys (though I seem to have become annoying to some), but I don't understand a lot of the issues I'm having.

The above code gives an unmatched braces error...

Code:

#regex movement {^I see no(?: \w+)? log here.$} {
if (@loading="off") {
#6 {#send "drag all.@current_board n" } }
{ loading="off" } } {General Triggers|Crafting}


This above code works... there's the same number of braces. All that's different is more commands and some whitespace. I'm very confused.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Apr 23, 2008 5:21 pm   
 
It's because you're not indenting properly. When you indent a line, CMUD acts as if it's still part of the previous line. Try this on the command line:

Code:
#say Hello
  there


So, because the line after the #if isn't indented, CMUD thinks that it's a new, unrelated line, which leaves the opening brace of the if hanging. You've also got tons of extra spaces all over the place (usually before closing braces) which might confuse the parser. It shouldn't be too hard for you to indent properly:

Code:
#regex movement {^I see no(?: \w+)? log here.$} {if (@loading="off") {
  #6 {#send "drag all.@current_board n"}
} {
  loading="off"
}
} {General Triggers|Crafting}


Also, you missed off the # before your if, and your variable @current_board won't be expanded because it's inside a string.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Wed Apr 23, 2008 5:26 pm; edited 2 times in total
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Apr 23, 2008 5:22 pm   
 
Your first example compiles for me, when put in the necessary semicolons on the command line:

Code:

#regex movement {^I see no(?: \w+)? log here.$} { if (@loading="off") { #6 {#send "drag all.@current_board n" }; drag all.@current_board e ; drag all.@current_board s ; drag all.@current_boardw ; drag all.@current_board d } { loading="off" } } {General Triggers|Crafting}


I see a bug in your sixth line: "@current_boardw" should be "@currentboard w". But that doesn't keep it from compiling.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Apr 23, 2008 5:27 pm   
 
Rahab wrote:
Your first example compiles for me, when put in the necessary semicolons

That's because it's a spacing issue. Putting it all on one line and using semicolons removes the problem (but it's ugly).
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Apr 23, 2008 5:44 pm   
 
Alright, thanks. But how am I going to know when it's indented properly? I can indent, but I already did indent a little, but apparently in a way CMUD doesn't like?
_________________
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: Wed Apr 23, 2008 5:46 pm   
 
You do have a bit of freedom. The main thing is that if you open a brace and immediately start a new line, you need to indent or it'll stop working.
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Apr 23, 2008 6:07 pm   
 
Indent by how much though?
_________________
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: Wed Apr 23, 2008 7:19 pm   
 
It doesn't matter, the important part is whether it's more indented than the previous line or not. Basically, two successive lines with no indentation change are assumed to have a semicolon between them. That's a vast simplification, so don't start picking it apart.

If you find this confusing, just pretend I said "two spaces" instead.
_________________
Rorso's syntax colouriser.

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


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Apr 23, 2008 10:26 pm   
 
hahahaha you don't have any respect for my intelligence. Shocked
_________________
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: Wed Apr 23, 2008 10:32 pm   
 
;)

Two spaces is the standard, really, after zMUD's pretty printer did it that way. So, if you use two spaces, you can't go wrong.
_________________
Rorso's syntax colouriser.

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


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Apr 23, 2008 11:21 pm   
 
It should be easy to figure out how much to indent when you look at the editor there is a line showing you where the block starts and ends. This is what I was talking about with your spacing and indention in that other post. Also you aren't annoying. I apologize if you thought I was rude to you in that other post as well.

I'm guessing you are creating EVERYTHING in notepad or something and then just pasting to the command line? Why not just create them in the editor and save yourself a lot of headache?

It's really about readability. Creating everything on one line separated by semicolons is not very readable. I can't stand when someone sends me a script that is like 50 lines long and it's all stuck on one line separated by semicolons. It's hard to tell where it starts and where it ends.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Apr 23, 2008 11:25 pm   
 
I'm creating them in notepad, yes.

I don't want to create in the editor because having them in notepad lets me replace them easily. I've had enough things crash or screw up that I like having every trigger in a text file ready to be reentered if needed.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Apr 23, 2008 11:28 pm   
 
By the way, you have other errors too. I'm pretty sure in that one line you want to drag west? You have the "w" attached to the end of your current_board variable.

Anyway, what I do as far as indention goes is like this. If you put that in the editor you can see how it draws a vertical line from the # to the }.

Code:

#regex movement {^I see no(?: \w+)? log here.$} {
  #if (@loading="off") {
    #6 {#send {drag all.@current_board n}}
    drag all.@current_board e
    drag all.@current_board s
    drag all.@current_board w
    drag all.@current_board d
  } { loading="off" }
} {General Triggers|Crafting}
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Wed Apr 23, 2008 11:33 pm   
 
chamenas wrote:
I'm creating them in notepad, yes.

I don't want to create in the editor because having them in notepad lets me replace them easily. I've had enough things crash or screw up that I like having every trigger in a text file ready to be reentered if needed.


Thought so. When I hit tab to indent in notepad it moves like 10 spaces.

Have any other editors?

Try downloading SciTE and use that instead. Then you can create your scripts how you want and have some syntax highlighting as well. You can even set indention to however many spaces you want.

http://www.scintilla.org/SciTE.html
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