• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Corutines

This
LUA:
Wait = createClass(nil)
Wait:setAttributes({
    co = nil
})

Wait.wait = coroutine.yield
function Wait:continue()
    if(self:co == nil or coroutine.status(self:co) == 'dead') then
        return false
    end

    local _, delay = coroutine.resume(self:co)
    addEvent(self:continue, delay)
    return true
end

function Wait:createObject(v)
    local f, vtype = v, type(v)
    if(vtype == 'string') then
        f = loadstring(v)
    elseif(vtype ~= 'function') then
        return false
    end

    self:co = coroutine.create(f)
    self:continue()
    return true
end
 
Back
Top