A wait command

Posted by Rhinoa on Tue 03 Sep 2002 02:20 AM — 15 posts, 59,777 views.

United Kingdom #0
Is there any way on making the world wait without using timers in VBS?

Like..
world.note "5 seconds will pass"
wait 5
world.note "Told ya :p"

Thanks in advance =)
~Rhinoa~
Australia Forum Administrator #1
This question keeps coming up. It must be popular! :)

You can't pause a script in that way, because the whole client would pause. You can do your example like this:


world.note "5 seconds will pass"
world.doafter 5, "Told ya :p"


For more complex examples, you need to make a timer (eg. a one-shot, temporary timer) that will fire in 5 seconds. That timer calls a script routine that does whatever it is you want to do in 5 seconds.
#2
but when the action to do is a path....

world.doafter 5, "Told ya :p"
^^^^^^^^^^
world.doafter 5, "#4w"

it just been send to the outwindow,but i mean go west 4 times.

and a question:

world.doafter 1, "A"
"B"

action "B" will be execute before "A",that's not my mean.

my mean is scripts wait 1 second ,and then do "A" and "world.doafter 1, "B"



Amended on Tue 15 Jun 2004 08:51 AM by Lhzooro
USA #3
For the first one youll need to make it a doafterspeedwalk:

world.DoAfterSpeedwalk 5, "4w"

should work.
#4
thank you..i have solve it ..

I think it's troubled when i have to wait 3 times on my path. Should I need to use DoAfter in a Doafter and in a DoAfter?

What I realy need is a function that cant pause a script for x second just like "#wait 1000" in the Zmud.

Is there have one in MUSHclient?
USA #5
No there isn't. You would have to suspend the script, have Mushclient wait a set amount of time, then continue in the same place. I have no idea of this is even possible, especially since while waiting the script could be called all over again. zMud gets by with it because 'it' does the scripting. There is something that can pause a script, but it has the side effect of freezing the client completely for that period of time, so nothing, including new text arriving, happens while paused.
Australia Forum Administrator #6
Quote:

Should I need to use DoAfter in a Doafter and in a DoAfter?


You can, but this is simpler:

DoAfter 5, "say hello"
DoAfter 6, "eat food"
DoAfter 7, "drink water"


This make you "say hello" after 5 seconds, then after one more second (6 in total) eat food, and then after another second drink water.
#7
Thanks a lot ..

I think the difrent between Zmud and Mush is that:

Zmud is running a Script and Mush is running a program which is translate from Script just like PERL.

Last Night I thinked an other idea about this:

Could I make a sub FUNCTION just wasting time?

like:
sub wait ()
for (i=0;i<1000000;$i++) {do nothing just cost time}
end sub

When I need to wait . I call this sub.
Could I?
:)
USA #8
How would that accomplish anything different then just pausing and doing nothing?
USA #9
When you did that, your WHOLE client would freeze. You wouldnt be able to do anything, you wouldnt recieve any text from the mud, or anything of the sort.

But yes, Mushclients scripting does allow you to simply call routines. Except that one wouldnt be very useful.
#10
PAUSE :
Description Turns on or off the "paused" flag for all output windows in this world.

PAUSE will stop the output windows.

These is a diffrent I think
USA #11
That merely stops the world from getting any new output. The client still recieves and sends and whatever, but the output window doesnt change position or have any new output.
Australia Forum Administrator #12
Quote:

sub wait ()
for (i=0;i<1000000;$i++) {do nothing just cost time}
end sub


This whole topic must have been covered, like, 100 times, but briefly, what that would do is take your CPU usage up to close to 100% for a while. Not only would it freeze the client, it would also go close to freezing everything else (eg. your mail program, your web browser).

It is a rather brute-force way of making a delay, and may not even work as intended.

For instance, if you did this:

Send "say hi there"
call wait
Send "say I'm back after 5 seconds"

That probably wouldn't even work. Why? Because your CPU loop that the "wait" sub is in would also stop the operating system from doing TCP/IP, thus your original "say hi there" would probably be in the bowels of the operating system "hanging" until it got the CPU back from your script.

Then the two messages would still be sent in quick succession (when the 5 seconds, or whatever, were up).
#13
Thanks for all.
:)
I now use lots of "DoAfter" in my programs.
Australia Forum Administrator #14
Quote:

What I realy need is a function that cant pause a script for x second just like "#wait 1000" in the Zmud.

Is there have one in MUSHclient?


See this post:


http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4956


This describes how to build pauses into scripts.