|
Spartacus Wanderer
Joined: 23 Apr 2001 Posts: 53 Location: USA
|
Posted: Thu Mar 17, 2005 12:01 am
Fishing |
Can one of you wizards tell me why this doesn't work?
@jerkMsgs is a list of possible results from jerking on my fishing pole. I have confirmed with #echo's (now removed) that I'm getting to the expected place in the #case command, but regardless of the #state commands issued, anytime this trigger fires, it falls straight through all four states.
Code: |
#TRIGGER "jerkDetector" {({@jerkMsgs})} {
#var jmNum {%ismember( %1, @jerkMsgs)} _nodef Fishing
#case @Fishing/jmNum {#state 1} {#state 2} {
#echo ~<FONT SIZE=16~>~<BOLD~>~<COLOR BLUE~>FISH ON!~</COLOR~>~</BOLD~>~</FONT~>
#state 3
}
}
#COND {You have recovered balance on all limbs.} {
jp
#state 0
}
#COND {You have recovered balance on all limbs.} {
tl
#state 0
}
#COND {You have recovered balance on all limbs.} {
rl
#state 0
} {prompt}
|
Thanks for your help! |
|
_________________ Spartacus
rm -rf .* |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Mar 17, 2005 2:17 am |
I really can't say why it doesn't work, but there are a few things that confuse me:
1. State 3 it set to prompt when none of the others are.
2. #var jmNum {%ismember( %1, @jerkMsgs)} _nodef Fishing is it so hard to put quotes and brackets in? I know zScript is very forgiving, but strict syntax is sometimes helpful. As a minimum you should quote the %1, and I suggest that since I have no clue about the contents of the jerkMsgs variable.
Minimum: #var jmNum {%ismember( "%1", @jerkMsgs)} _nodef Fishing
Strict: #VARIABLE jmNum {%ismember( "%1", @jerkMsgs)} "_nodef" {Fishing}
3. While the use of #STATE to implicitly refer to the containing trigger is documented and supported; I find it best to be explicit. This makes me horrible beta tester at times, but it may occasionally eliminate debugging headaches and ensures that your scripts tend to work through minor bugs. Suggested: #STATE jerkDetector 1
4. Why even use multiple states all designed to trigger on the same text? Eliminate the use of the #STATE command entirely.
Code: |
#TRIGGER "jerkDetector" {({@jerkMsgs})} {
#var jmNum {%ismember( %1, @jerkMsgs)} _nodef Fishing
}
#COND {You have recovered balance on all limbs.} {
#case @Fishing/jmNum {jp} {tl} {
#echo ~<FONT SIZE=16~>~<BOLD~>~<COLOR BLUE~>FISH ON!~</COLOR~>~</BOLD~>~</FONT~>
rl
}
} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Spartacus Wanderer
Joined: 23 Apr 2001 Posts: 53 Location: USA
|
Posted: Thu Mar 17, 2005 3:45 am |
But... but... but... that's so much EASIER! And slicker... and better...
Thanks! |
|
_________________ Spartacus
rm -rf .* |
|
|
|
Spartacus Wanderer
Joined: 23 Apr 2001 Posts: 53 Location: USA
|
Posted: Thu Mar 17, 2005 5:29 pm Strict Syntax |
Vijilante wrote: |
2. #var jmNum {%ismember( %1, @jerkMsgs)} _nodef Fishing is it so hard to put quotes and brackets in? I know zScript is very forgiving, but strict syntax is sometimes helpful. As a minimum you should quote the %1, and I suggest that since I have no clue about the contents of the jerkMsgs variable. |
No offense intended, Vij, but the reason I can't be bothered about strict syntax is that I don't know what it is. I'd love to keep strict syntax, but I build my scripts based on examples and documentation in zMUD's help files which I am probably 85-90% effective at reading. I try to mimic the syntax used in those examples unless they are specifically marked as things not to do.
A good example of what I'm talking about here is the help file on #VARIABLE. I'm not sure that there is a single example in that file which uses what you would consider strict syntax - or maybe I just don't understand what you mean be strict syntax.
Anyway, if I understood a previous post you made, you are in the process of rewriting the help system and if that's correct, I'm very anxious to see the results! In the meantime, is there a reference you could point us to that defines what strict syntax is?
Thanks! |
|
_________________ Spartacus
rm -rf .* |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Mar 17, 2005 11:11 pm |
I am always in the process of rewriting the help. I actually have to buckle down this weekend and get a bunch more things done then work out how to post an update. Strict syntax is basically delimiting every parameter for a command properly so the parser doesn't have to guess about it. I know most of the examples are not done with strict syntax. It was enough for me about 1.5 years ago to just read through every topic and try to make sure that every single one had examples, as well as rebuilding the contents, index, and creating the related buttons. I have been meaning to put in a page on the subject of delimeters since it seems to cause problems frequently, but deciding where to put it and how to link it to make it findable without going through every topic again is part of the delay. That and I have 17 other projects I am still trying to work on.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Spartacus Wanderer
Joined: 23 Apr 2001 Posts: 53 Location: USA
|
Posted: Sun Mar 20, 2005 6:51 am |
That's cool - as I said, I'm looking forward to seeing some updates - I know zMUD has a lot more power than I'm using and having some more depth in the help files might help me there.
BTW - You should be aware, that what you referred to as strict syntax in your earlier message actually had an error:
Quote: |
Strict: #VARIABLE jmNum {%ismember( "%1", @jerkMsgs)} "_nodef" {Fishing} |
This sets the default value of jmNum to "_nodef" rather than giving it no default value which is what _nodef without the quotes does. |
|
_________________ Spartacus
rm -rf .* |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Mar 20, 2005 6:48 pm |
Yep should be braces instead of the quotes. No matter how much anyone works with zMud they still make mistakes, even Zugg. That is why the forums are here and there are so many helpful people around.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
|
|