Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Trigger match failed for the sequential of wait.regexp() and Execute()
|
Trigger match failed for the sequential of wait.regexp() and Execute()
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
| Posted by
| Fiendish
USA (2,555 posts) Bio
Global Moderator |
| Date
| Reply #15 on Fri 26 Jul 2019 07:57 PM (UTC) Amended on Fri 26 Jul 2019 08:00 PM (UTC) by Fiendish
|
| Message
|
Quote: While the wait.regexp creates the trigger just after the match line is generated. There is a chance that the match line comes while trigger has not been created by wait.regexp.
I don't think this is true. MUSHclient only has one thread, so all processing happens sequentially. The order of events from your example should always be "send message to mud, create trigger, process response from mud after trigger is created" even if the MUD manages to respond so fast that the response comes back in the nanosecond between your two lines of code (this is actually impossible). |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #16 on Fri 26 Jul 2019 09:58 PM (UTC) |
| Message
|
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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #17 on Fri 26 Jul 2019 10:01 PM (UTC) |
| Message
|
Fiendish said:
I don't think this is true. MUSHclient only has one thread, so all processing happens sequentially.
In the case of the wait module, though, control passes back to the client as the coroutine suspends, thus the next line in the script is not actually processed sequentially.
Although the trigger would appear to exist at this point, perhaps a higher-priority trigger gets to the line first. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Zhenzh
China (68 posts) Bio
|
| Date
| Reply #18 on Sat 27 Jul 2019 03:37 AM (UTC) |
| Message
|
Fiendish said:
The order of events from your example should always be "send message to mud, create trigger, process response from mud after trigger is created"
I used to think so until I had a simple test.
wait.make(function()
Execute("say this is a test")
wait.time(5)
l,_ = wait.regexp("this is a test", 10)
Note(l)
end)
I manually added a wait.time() action between Execute() and wait.regexp() to simulate network issue.
The test result shows the trigger will fail as the point of time the trigger created is after the time the mud server response Execute() | | Top |
|
| Posted by
| Zhenzh
China (68 posts) Bio
|
| Date
| Reply #19 on Sat 27 Jul 2019 03:58 AM (UTC) |
| Message
|
Nick Gammon said:
You can unwind that and do it manually:
•Make a trigger
•Make a timer if you want to handle time-out
•Send your message
Yes, I processed my script in such way as work around using AddTriggerEx(),Execute() instead of Execute(),wait.regexp().
I just wonder if there is a formal way to process such case.
For the wait.regexp() is an import and useful function in most cases. Such issue may get it unreliable in some scenario.
I'd like to adjust the wait module, adding a fourth parameter which is action users may want to be executed during AddTriggerEX() and coroutine.yield() in function regexp(). So that the wait.regexp() can get reliable in the Execute(),wait.regexp() cases and end user do not need to manually addtrigger,addtimer,execute,yield each time.
What's your opinion? | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
67,494 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top