If do wait.regexp first, the script will be paused to wait the match
line coming so that the next action, Execute() will not be happened
until the regexp detecting the match line or timeout.
Yes, I understand that. However there is nothing stopping you making
a trigger to match the expected text, sending the message and then
exiting this particular script. Then when the trigger fires you can
process it.
All that the wait module basically does it simplify this
procedure:
- It makes a Lua coroutine
- It make a trigger (for the match)
- It makes a timer (for the timeout)
- The coroutine suspends, passing control back to the client
Then when the trigger (or timer) fires the coroutine resumes at the
next line in your script.
You can unwind that and do it manually:
- Make a trigger
- Make a timer if you want to handle time-out
- Send your message
Now things are in the right order, the trigger is there if the
response comes back quickly.
When the trigger fires you process it. This effectively gives you two
lots of script: One to make the trigger and send the message, the second
to process the trigger.