I've got a script that when triggered is supposed to cast the same spell until I fall below a certain amount of mana. Instead of using timers, I just did a DoAfter in a while loop. A trigger is set to call a function that sets a boolean when my mana drops. However when this train function is called, mushclient simply locks up. If I do a DoAfter outside of the loop, it executes the command immediately with no pause. Here's the snippet.
function train()
{
var counter = 0;
while(aboveManaLimit)
{
world.Note("Iteration " + counter);
var temp = counter % 3; //every third cast, check where.
if(!temp)
{
world.Execute("where");
}
world.DoAfter (3, spellName); //This is what's failing.
counter++;
}
goToSleep();
}