Pausing

Posted by James Friel on Tue 10 Apr 2001 09:06 PM — 5 posts, 33,997 views.

#0
Now that i finally got into the forums i want to find out how to put a pause into your script file. I have a simple script to attack a target over and over, but i need a 5 second pause inbetween each attack to match up with the built in 5 second pause of the game.

my basic script is like this

sub fight
dim icounter
for icounter=1 to 500
world.send "attack target"
next
end sub


not this lets me attack the target 500 times in a row, but i need a pause after the world.send line, but i don't know how to put pauses into the script. i looked about alot, but didn't find any in-script commands to do this.
help! he he . thanks.
Australia Forum Administrator #1
You can't easily pause a script as such, because scripts are supposed to run as fast as possible, otherwise the whole program would slow down.

However what you can do is do it a bit differently. A simple solution is to use a timer.



sub fight 
  world.addtimer "my_timer", 0, 0, 5, "attack target", 1025, "On_Timer_Fired"
  world.setvariable "attack_count", 0
end sub 



What this code will do is add a timer called "my_timer" that fires every 5 seconds. When it fires it sends "attack target". Also when it fires it calls "On_Timer_Fired". This counts up to 500 for you.




sub On_Timer_Fired (strTimerName)
dim count
' count attacks
  count = world.getvariable ("attack_count") + 1
  if count >= 500 then
    world.deletetimer "my_timer"
  else
    world.setvariable "attack_count", count
  end if
end sub



This script counts the number of times the timer fired, and when it reaches 500 deletes it. You could also make another trigger which matches on when your target is killed, which calls a trigger script that deletes the timer also, something like this:



sub On_Target_Dead (strTriggerName, strTriggerLine, aryWildcards)
  world.deletetimer "my_timer"
end sub




Amended on Tue 10 Apr 2001 10:21 PM by Nick Gammon
#2
I wanted to do something similar but I used world.SpeedWalkDelay and world.queue only without the world.evaluatespeedwalk

http://www.mushclient.com/scripts/function.php?name=SpeedWalkDelay

http://www.mushclient.com/scripts/function.php?name=Queue
#3
No offense, but that seems like an awful lot of work when all I may want is just a simple pause in a script before moving on.

Take for instance, Achaea - you have "balances" where you can't slam potions one after another. You have to wait. Now if I'm writing a fighting alias, I may want to do something like this:

take a potion
(pause for 2 seconds to wait for balance)
take the 2nd potion
rub some salve
eat something

Now to make 3 functions, and one timer, to do just a pause in an alias or even a script, just seems like overkill. No offense meant.

I guess I would suggest that we have something similar to Zmud where we could do that. Sure, we can use scripting, but it would be nice to just stick that in the alias itself... or have a simple "pause/wait" that would be stuck in the script or alias.

Regards,
Neurowiz
Australia Forum Administrator #4
Sure, you can do a simple thing like that, simply ... :)

Have the alias call a small script like this:


sub MyAliasScript (a, b, c)
world.send "take a potion"
world.doafter 2, "take the 2nd potion"
world.doafter 3, "rub some salve"
world.doafter 3, "eat something"
end sub

What this does is immediately take the potion, wait 2 seconds, and take the second one, wait a further second (a total of 3 seconds) rub the salve and immediately eat something.

This isn't very complex.

The alias needs 3 arguments, since we aren't using them I am calling them "a", "b" and "c" to save typing.
Amended on Sat 26 Oct 2002 12:04 AM by Nick Gammon