|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Tue Mar 03, 2009 1:13 am
[SOLVED] More Anger at Nesting Problems |
*explodes*
...much better. Hello, I am once again having issues with formatting and odd errors that shouldn't be there. It's such a recurrent problem for me that I thought I'd eventually learned the trick to nesting in CMUD. However, it's clear I haven't learned anything because no matter what I do to adjust the formatting, I get an "unmatched braces" error. None of the braces appear to be unpaird, the formatting looks fine, even all the color coding is there and yet the error appears. What am I doing wrong now? How can I prevent it in the future?
Code: |
<trigger name="spellbot-t2" priority="980" regex="true" id="98">
<pattern>^(?:\(Imm\) )?(?:The ghost of )?([\w']+|A masked swashbuckler|\(An Imm\)){1,2} tells you (?:\([^\)]+\) )?\'(dd:(?: )?\'(.*)\'(?: (.*))?)\'</pattern>
<value>#IF ((%begins("permanency",%3)) OR (%begins("chain lightning", %3)) OR (%begins("fireball", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)))
{
#send {"reply Not on your life, try another. (ooc: Automated response to spellbot request)"}
}
{
#IF (%4=%null)
{
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"'"}
#send {$cur_posn @bed}
regen
}
{
#IF(%3 == "nexus")
{
$cur_posn=@posn
#send {"stand"}
#send {"down"}
#send {"north"}
#send {"get 'glit whit' vault"}
#send {"south"}
#send {"hold 'glit white'"}
#send {"c '"%3"' "%4}
#send {"hold tome"}
#send {"up"}
#send {$cur_posn @bed}
regen
}
{
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"' "%4}
#send {$cur_posn @bed}
regen
}
}
}
</value>
</trigger>
|
|
|
_________________ Listen to my Guitar - If you like it, listen to more
Last edited by chamenas on Tue Mar 03, 2009 3:45 am; edited 1 time in total |
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Tue Mar 03, 2009 2:16 am |
needs a space
Code: |
#IF (%3 == "nexus") |
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Mar 03, 2009 2:16 am |
You could perhaps try using a more orthodox formatting system. The problem I suspect is line two and also line 5 - because they're not indented relative to the #if command, they're treated as new commands rather than a continuation of the previous line. I explain this in a bit more detail here.
You can see that it's doing this because normally, an #if generates a code folding node which, if clicked, will hide the entire #if up until the terminating brace of its else-command (or its true-command if it doesn't have an else-command). You can see in the editor that it isn't doing this - instead, line 2 has its own folding node, and line 5 has another - because the parser is seeing them as separate commands.
There're some basic rules to follow here but it's much easier to show you how than try to explain, so here goes:
Code: |
#IF ((%begins("permanency",%3)) OR (%begins("chain lightning", %3)) OR (%begins("fireball", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3)) OR (%begins("disjunction", %3)) OR (%begins("acid blast", %3)) OR (%begins("blizzra", %3))) {
#send "reply Not on your life, try another. (ooc: Automated response to spellbot request)"
} {
#IF (%4=%null) {
$cur_posn=@posn
#send "stand"
#send "c '"%3"'"
#send {$cur_posn @bed}
regen
} {
#IF(%3 == "nexus") {
$cur_posn=@posn
#send "stand"
#send "down"
#send "north"
#send "get 'glit whit' vault"
#send "south"
#send "hold 'glit white'"
#send "c '"%3"' "%4
#send "hold tome"
#send "up"
#send {$cur_posn @bed}
regen
} {
$cur_posn=@posn
#send {"stand"}
#send {"c '"%3"' "%4}
#send {$cur_posn @bed}
regen
}
}
} |
(You also don't need {} if you're already using "".)
This is the system that zMUD's pretty printer uses, and it's never failed me.
...except for now. I note that even after reformatting your script this way, I'm still getting the error - which, I guess, means it was never a formatting problem at all. I still recommend using the scheme I outlined above, because that way code folding will start working for you, though. I must confess that my first thought when you post code is usually "my lord, that code is ugly".
Ah, yes, I've found the error. The problem, in fact, is a missing space - line 17 of the original script, line 11 of my edited script. How did I spot this error? I just pressed ctrl+k and it took me right to the offending line. The colour highlighting wasn't working for the items inside the expression and hey, there's the problem. The formatting was fine.
Next time, try running a syntax check first :P |
|
|
|
|
|
|
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
|
|