Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
RobMacAF
Apprentice


Joined: 09 Jun 2002
Posts: 186
Location: USA

PostPosted: Mon Jul 26, 2004 10:57 am   

My Alias keeps repeating and I don't know why
 
Ok, This is the only alias i have ever seen do this. It goes through it then starts back over.....I can't figure out why

ALIAS NAME: TakeTurn

Here is the script:
-------------------------------------

say You have these abilities
#VAR tmp 0
#WHILE (@tmp != 6) {
#ADD tmp 1
#IF (%db( @IsTurn, Ability@tmp) != "") {
say @tmp - %db( @IsTurn, Ability@tmp)
#WAIT 2000
}
}
say To play one please say, CAST ABILITY

--------------------------------------

Am I blind and am missing something?
Reply with quote
luggage
Novice


Joined: 20 Jul 2004
Posts: 38
Location: Australia

PostPosted: Mon Jul 26, 2004 12:23 pm   
 
Looking at your while statement, I'm not sure what happens to the @tmp variable with the database commands, as I have never looked into that area, but I'm guessing that the @tmp variable never hits the number 6. I prefer when using counters in WHILE loops to use a '<' or '>' instead of hoping to hit a certain number.
E.g.
#WHILE (@tmp < 5) {

That way, if you make a mistake, the while loop will still bomb out hopefully. Another check is to include a statement at the end of the while loop that displays the contents of the @tmp variable.
E.g.
#SHOW TMP Variable is @tmp

Then you can easily see what is happening with the variable just before it gets checked with your WHILE loop. Or use the inbuilt debugger in zmud and set a watch on your @tmp variable and you can see what happens to the variable after each statement is executed.

Luggage
Reply with quote
geniusclown
Magician


Joined: 23 Apr 2003
Posts: 358
Location: USA

PostPosted: Mon Jul 26, 2004 2:03 pm   
 
I recently had an alias that would repeat itself unpredicatably (sometimes it would repeat 10 times, sometimes not at all). It contained a #FORALL with a #WAIT inside it. I rewrote the script to not use #WAIT, and it solved the problem.

Here's what I started with, that caused the problem:
Quote:
#TR {^You also find (*){!|.}$} {
loot = %replace(%replace(%1,", ","|")," ","|")
#FORALL @loot {#IF (%ismember(%i,@Keepers)) {
get %i
stow %i
#WAIT 500
}
}

This little script will turn what I found into a list of the individual words, which it then checks to see if it's in my list of Keepers... this way, it will match a medium star crystal or a small star crystal the same (because it's just trying to match each word, and "crystal" is in both). The result would be that if I found a crystal, the script would often pick up the crystal, stow it, pull it out, stow it, pull it out, stow it, pull it out, stow it.

Here's my solution:
Quote:
#TR {^You also find (*){!|.}$} {
loot = %replace(%replace(%1,", ","|")," ","|")
#FORALL @loot {#IF (%ismember(%i,@Keepers)) {Looting=%additem(%i,@Looting)}}
#TR {@Looting} {Lootitem=%pop(Looting);get @Lootitem} "" {Exp}
#COND {^You {get|pick up}} {stow @Lootitem}

This solution requires a couple extra variables, and a multistate trigger, but it works flawlessly.

Bottom line is, if you ever use #WAIT, and you encounter a strange error with the script, then try to work the #WAIT out of it.

I hope this helps!
_________________
.geniusclown
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Mon Jul 26, 2004 6:01 pm   
 
It's hard to evaluate a script when you leave out one of its major elements, the @IsTurn variable. However, I made up some stuff and tested it, and the alias doesn't repeat. Check the trigger or other settings you use to call this alias. Also check for other settings which alter @tmp.

NOTE: You should avoid using this alias from a trigger since it uses the #WAIT command.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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