Page 2 of 2

Re: Can I create a custom event?

Posted: Sat Apr 18, 2020 3:21 pm
by zhenzh
I see. But the manually raising event inside function introduces a new issue to be resolved.
Invoking raiseEvent() in my case is equal to invoking send() directly (raiseEvent->wait_event->send)
Then, the function should look like:

Code: Select all

function wait_line(pattern, action)
    thread = coroutin.running()
    tempTrigger(pattern, [[wait_resume()]], 1)
    send(action)
    return coroutin.yield()
end
We expect the regular flow should be
trigger create -> send action -> coroutin.yield -> pattern coming(get response for send) -> trigger fired -> resume
While for some unexpected reason(network, server/client cpu and etc.), there may be chance the flow becomes
trigger create -> send action -> pattern coming(mud server response as fast as possible) -> trigger fired -> resume(nothing occurr as yield has not come) -> coroutin.yield
If the second case occur, the wait_line will trap in waiting forever.

Re: Can I create a custom event?

Posted: Sat Apr 18, 2020 3:42 pm
by Vadi
Remember you can also pass closures/anonymous functions to tempTrigger, maybe that helps?

Re: Can I create a custom event?

Posted: Sun Apr 19, 2020 11:54 am
by zhenzh
Finially I get ride of using event and use a loop instead.
Attached my package.

Re: Can I create a custom event?

Posted: Sun Apr 19, 2020 12:14 pm
by Vadi
Nice! and some examples on how to use? With screenshots would be good.

If you could make a new thread in the scripts forum, that'd help people find it a lot easier.

Re: Can I create a custom event?

Posted: Sun Apr 19, 2020 1:08 pm
by zhenzh
Well, I'll share it in script forum with usage :)