pause or delay

Looking for suggestions on how to create a delay in my game. this is what im trying to do.
its a 3 in a row Classic puzzle game. match 3 or more of the same color and those “colors” are removed and new colors fall down. potentially creating new 3 in a row matches.

My code looks something like this

function checkMixedColors()
– looks for 3 in a row if found then flag and call function score() Else do nothing…

function score()
– Handels scoring and calls function moveBrushDown()

handle score…
call moveBrushDown()…
call checkMixedColors()…?

in this function after moveBrushDown function is complete i would like to call function checkMixedColors() to see if there are any new 3 in a row. howver, i need to wait until the tween function in moveBrushDown is done or it Will find matches and start handling this before the player even knows what is goding on. is it posdible to get some directions on were to look and how to think?

function moveBrushDown()
– animates brushes falling down. this is set to take 1 sec using tween()

the formating of the text is unreadable… here is the code…


 
-- check for matched color combos
function checkMixedColors()
    local scoreFound = false
    for i=1, 6 do      
        local rowCount = 0
        local rowMaxCount = 1
        local rowCombo = {}
        local rowColor = nil
        local columCount = 0
        local columMaxCount = 1
        local columCombo = {}
        local columColor = nil
        for j=1, 6 do
            -- check for +3 in a row in rows first
            if palette[i][j].col == rowColor then
                rowCount = rowCount + 1             
                if rowCount > rowMaxCount then
                    rowMaxCount = rowMaxCount + 1
                    rowCombo[#rowCombo+1] = palette[i][j].ind
                end
            else
                rowColor = palette[i][j].col
                rowCount = 1
                if rowMaxCount == 1 then
                    rowCombo[1] = palette[i][j].ind
                end
            end
            -- then check for +3 in a row in colums     
            if palette[j][i].col == columColor then
                columCount = columCount + 1             
                if columCount > columMaxCount then
                    columMaxCount = columMaxCount + 1
                    columCombo[#columCombo+1] = palette[j][i].ind
                end
            else
                columColor = palette[j][i].col
                columCount = 1
                if columMaxCount == 1 then
                    columCombo[1] = palette[j][i].ind
                end
            end          
        end
        -- if we find +3 in a row then mark witch brushes to score
        if rowMaxCount >= 3 then
            scoreFound = true
            --print("rowcombo = "..tostring(#rowCombo))
            for i=1, #rowCombo do
                resolveCombo(rowCombo)
            end
        end
        if columMaxCount >= 3 then
            scoreFound = true
            --print("columcombo = "..tostring(#columCombo))
            for i=1, #columCombo do
                resolveCombo(columCombo)
            end
        end
    end
    if scoreFound == true then
        score()
    end
end
 
-- set which brushes generate a score
function resolveCombo(combo)
    for counter=1, #combo do
        for i=1, 6 do
            for j=1, 6 do
                if palette[i][j].ind == combo[counter] then
                    palette[i][j].score = true
                    --print("score id = "..palette[i][j].ind)
                end
            end
        end
    end
end
 
function score()
    -- increase player score
    for i=1, 6 do
        for j=1, 6 do
            if palette[i][j].score == true then
                playerScore = playerScore + 1
            end
        end
    end
    
    moveBrushDown()
    
    --set all score flags to false
    for i=1, 6 do
        for j=1, 6 do
            palette[i][j].score = false
        end
    end  
    -- check if new combos have been created by falling brushes
    --checkMixedColors()
end

function moveBrushDown()
    local numberOfHoles = {}
    local staticBrushPositions = {}
    local pw = math.min(WIDTH,HEIGHT)
    local ph = pw
    local bw = pw/6
    local bh = pw/6
    local sx = bw/2
    local sy = bh/2
    for i=1, 12 do      
        staticBrushPositions[i] = {}
        for j=1, 6 do
            staticBrushPositions[i][j] = vec2(sx, sy)
            sx = sx + bw
        end
        sx = bw/2
        sy = sy + bh
    end       
    for i=1, 6 do
        local count = 0
        numberOfHoles[i] = {}
        for j=1, 6 do
            if palette[j][i].score == true then
                count = count + 1
            end
            numberOfHoles[i][j] = count
        end
        for j=1, 6 do
            local nextFreeNoScoringBrush = numberOfHoles[i][j]
            local endPos = palette[j][i].pos
            palette[j][i].pos = staticBrushPositions[j+nextFreeNoScoringBrush][i]
            palette[j][i].col = palette[j+nextFreeNoScoringBrush][i].col
            tween(1, palette[j][i].pos, {x=endPos.x, y=endPos.y})
        end
    end
    setNewInvisibleColors()
end

Call it in the callback of your tween?

tween.delay(1.04,checkMixedColors) would execute it a frame after your tween finishes, but as @Coder said putting it in your current tween should work as you can add a callback to the end of the tween call.

@coder @luatee thanks
tween.delay(1.05, function() checkMixedColors() end)

worked like a charm. took me a while to understand i had to write function as well()