-- thread utils function wait(t) coroutine.yield(t) end function thread(cb) local co = coroutine.create(cb) local function resumefun() if coroutine.status(co) == "dead" then return end local suc, time = coroutine.resume(co) if not suc then error(debug.traceback(co)) end if suc and time then g_settimer(time, false, resumefun) end end resumefun() return co end function killthread(co) coroutine.close(co) end