|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Sun Apr 08, 2007 2:57 am
Parsing problem?? This -should- work but isnt |
sorry about the vague subject but i'm not even sure which part of this is wrong and causing such a headache...
Essentially, ive got a controlling alias called MAKE which cycles through and calls various crafting aliases 1 at a time.
The following script works perfectly in zMud and as far as i can see should be working in cMud as well but instead spams the mud:
#VAR count %1
#VAR item %2
#IF (%isnumber(@count)) {
#WHILE (@count>0) {
@item
#ADD count -1
}
} {
#VAR item @count
#VAR count 1
}
NOTE: originally instead of #VAR, I was using direct a=b variable assignment and changed it to see if it helped... but it hasnt changed the result
As a test, I entered in Make 1 fudgecookie on the command line - where fudgecookie is my alias to bake 1 cookie
What i'm getting is the following 2 lines spammed endlessly till I hit ESC
fudgecookie
#ADD count -1
fudgecookie
#ADD count -1
I is supposed to run the fudgecookie alias, wait till it finishes then decrement 1 from @count and repeat till count reaches 0
Intead, it appears to be sending the whole lot at once and never decrementing.
Is this a parsing problem or am I missing some crucial difference between zMud and cMud coding ?
EDIT: I should add that I am using ver 1.26 |
|
_________________ What do you mean, Fatal Error! |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Apr 08, 2007 3:28 am |
Your problem comes because you haven't told CMUD what to do with the returned value of @item - change it to "#exec @item" and it'll work just fine. You could also make the script a bit neater with local variables if you want:
Code: |
#alias make($count,$item) {#if %isnumber($count) {
#WHILE ($count>0) {
#exec $item
#ADD $count -1
}
} {
#exec $item
}} |
EDIT: Though while I'm thinking about it, does #add work with local variables? #additem and such don't, so it's possible that #add doesn't either. You could use %math or %eval instead I suppose but that sort of defies the point of making it neater :P |
|
Last edited by Fang Xianfu on Sun Apr 08, 2007 3:34 am; edited 4 times in total |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Apr 08, 2007 3:30 am |
You can't use @item by itself anymore to run aliases (probably anything code related, like zscript commands or functions). To do so, use #EXEC @item.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Chris_3413 Novice
Joined: 22 Mar 2004 Posts: 46 Location: Australia
|
Posted: Sat Apr 21, 2007 5:01 am |
bleh.. knew there had to be a simple explaination for it... thanks guys, it all works perfectly now
|
|
_________________ What do you mean, Fatal Error! |
|
|
|
|
|