From bd44d42ab46420decd62d53a0867d96c3ea1f93f Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Thu, 4 Jan 2018 14:35:10 +0800 Subject: [PATCH] Add multiple event waiting support --- libevent.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libevent.lua b/libevent.lua index 98af64e..c1600b1 100644 --- a/libevent.lua +++ b/libevent.lua @@ -166,10 +166,20 @@ function WaitEvent(...) elseif(type(tb[1])=="number") then -- WaitEvent(1),event.pull(1) return doEventTranslate(table.pack(event.pull(tb[1]))) else - error("syntax error. Usage: WaitEvent([EventName],[TimeOutSecond])") + error("Syntax error. Usage: WaitEvent([EventName],[TimeOutSecond])") end end +function WaitMultipleEvent(...) + local tb=table.pack(...) + for i=1,tb.n,1 do + if(type(tb[i])~="string") then + error("Syntax error. Usage: WaitMultipleEvent(EventName1,[EventName2]...)") + end + end + return doEventTranslate(table.pack(event.pullMultiple(...))) +end + function PushEvent(EventName,...) checkstring(EventName) return event.push(EventName,...)