About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

 Related 
Contents
Threads
  #RESUME
  #SECTION
  #SIGNAL
  #STOP
  #SUSPEND
  #THREAD
  #WAIT
  #WAITSIGNAL
  #WAITTHREAD
  %section
  %threadid
  %threadname
  Threads
Command Reference
  #nnn
  #ABORT
  #ACTION
  #ADD
  #ADDITEM
  #ADDKEY
  #AFK
  #ALARM
  #ALIAS
  #ALL
  #BACKUP
  #BEEP
  #BREAK
  #BUTTON
  #C-
  #C+
  #CALL
  #CAPTURE
  #CASE
  #CHARACTER
  #CLASS
  #CLOSE
  #CLR
  #CMD
  #COLOR
  #COM
  #CONDITION
  #CONFIGURE
  #CONNECT
  #CONTINUE
  #CR
  #CW
  #DBCLOSE
  #DBDELETE
  #DBFIRST
  #DBGET
  #DBLOAD
  #DBNEXT
  #DBOFFLINE
  #DBONLINE
  #DBPREV
  #DBPUT
  #DBRESET
  #DBSAVE
  #DDE
  #DEBUG
  #DEBUGFILE
  #DEFAULT
  #DELCLASS
  #DELITEM
  #DELKEY
  #DELNITEM
  #DESCRIBE
  #DIRECTION
  #DISCONNECT
  #DOOR
  #ECHO
  #ECHOPROMPT
  #EDITOR
  #ERASE
  #EVALUATE
  #EVENT
  #EXECUTE
  #EXECWIN
  #EXIT
  #FILE
  #FIND
  #FIRE
  #FORALL
  #FREEZE
  #FTP
  #FUNCTION
  #GAG
  #GAGBLOCK
  #GAGLOG
  #GAGOFF
  #GAGON
  #GAGSPACE
  #GAUGE
  #H-
  #H+
  #HELP
  #HIGHLIGHT
  #HISTLOAD
  #HISTORY
  #HISTSAVE
  #HOST
  #IF
  #IGNORE
  #IMAGE
  #INPUT
  #KEY
  #KILLALL
  #LAUNCH
  #LMAP
  #LOAD
  #LOCAL
  #LOCATION
  #LOG
  #LOOK
  #LOOP
  #LOOPDB
  #LOOPVIEW
  #LUA
  #MAKEROOM
  #MAKEWINDOW
  #MAP
  #MAPQUERY
  #MARK
  #MATH
  #MEDIA
  #MENU
  #MERGE
  #MESSAGE
  #MODULE
  #MOVE
  #MSS
  #MXP
  #MXPTRIG
  #NAME
  #NEW
  #NEWVAR
  #NODEF
  #NODIR
  #NOINPUT
  #NOMAP
  #NOOP
  #NOSAVE
  #OK
  #ONINPUT
  #PATH
  #PATHHIGH
  #PAUSE
  #PCOL
  #PICK
  #PLAY
  #PLUGIN
  #PORTAL
  #PRINT
  #PROMPT
  #PSUB
  #PUEBLO
  #PW
  #QUERY
  #QUEUE
  #RAISEEVENT
  #READ
  #RECALL
  #RECORD
  #REGEX
  #RENAME
  #REPEAT
  #RESET
  #RESUME
  #RESULT
  #RETRACE
  #RETURN
  #SAVE
  #SAY
  #SAYADD
  #SAYPROMPT
  #SCRIPT
  #SCROLL
  #SECTION
  #SEND
  #SENDGMCP
  #SENDPROMPT
  #SENDRAW
  #SENDSB
  #SESSION
  #SET
  #SETPROMPT
  #SHOW
  #SHOWARR
  #SHOWDB
  #SHOWPROMPT
  #SHOWTABLE
  #SIGNAL
  #SLOW
  #SORT
  #SQLCLOSE
  #SQLDB
  #SS
  #STATE
  #STATUS
  #STEP
  #STOP
  #STWIN
  #STYLE
  #SUBSTITUTE
  #SUSPEND
  #SWITCH
  #T-
  #T?
  #T+
  #TAB
  #TAG
  #TELEPORT
  #TEMP
  #TEMPVAR
  #THREAD
  #TIMER
  #TRACK
  #TRIGGER
  #TSET
  #TYPE
  #TZERO
  #UNALIAS
  #UNBUTTON
  #UNCLASS
  #UNDIR
  #UNGAG
  #UNKEY
  #UNEVENT
  #UNLOAD
  #UNLOC
  #UNMENU
  #UNPATH
  #UNPORTAL
  #UNSTYLE
  #UNTAB
  #UNTIL
  #UNTRIGGER
  #UNVAR
  #UPDATE
  #URL
  #VARFUNC
  #VARIABLE
  #VERBATIM
  #VERSION
  #VIEW
  #WAIT
  #WAITFOR
  #WAITSIGNAL
  #WAITTHREAD
  #WALK
  #WHILE
  #WINDOW
  #WITHLOC
  #WIZLIST
  #WRAP
  #WRITE
  #WRITELOG
  #YESNO
Related Links:
  Threads
  #THREAD
  #SECTION
#WAITFOR [[cmud_#WAITFOR]] 
Added in v2.0
WAITFOR

Syntax: #WAITFOR {pattern} timeout {match-commands} {timeout-commands}

Suspends the current thread and waits for a line from the server that matches the specified pattern. If timeout is specified, it indicates the number of milliseconds to wait before giving up. If the timeout expires, the rest of the thread's script is aborted.

The match-commands and timeout-commands are optional command blocks that should be executed when the pattern is received, or when the timeout occurs. If these are omitted, then the script will continue with the next statement when the pattern is received, and will exit the script if a timeout occurs.

NOTE: Normally it is better to create a trigger that fires when a pattern is received from the MUD. Using WAITFOR will suspend the current thread and will cause parallel threads to be running at the same time. For complicated scripts, using triggers can prevent thread synchronization problems. So WAITFOR should only be used for simple scripts that do not access any global resources.

WAITFOR example

#WAITFOR {^Username:}
#CHAR
#WAITFOR {^Password:} 1000
#PW

Waits for the string "Username:" to be sent at the beginning of a line, and then sends the user's character name, then waits one second for the server to send the "Password:" string, and then sends the user's password back to the server.

#ALIAS recall {
#SEND recall
#WAITFOR {The Temple Square} 3000 {#RECALL} {#SAY Recall failed!}
}

In this example, we create an alias for the "recall" command. It sends "recall" to the MUD, then waits to see the name of the room that we are recalling to. If the room name is received within 3 seconds, then we use the #RECALL command to update the mapper position. Otherwise the mapper position is not updated and we display "Recall failed!" to the screen.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net