[Solved] Variable Function Parameters

Hello :slight_smile:
Can someone please explain?

-- cr

-- Use this function to perform your initial setup
function setup()
    textMode(CENTER)
    print(_VERSION)
    sinput = "This is a"
    soutput = "Test"
end

-- This function gets called once every frame
function draw()
    background(0, 0, 0, 255)
    drawText(sinput, soutput)
end

function drawText(...)
    fill(255, 255, 255, 255)
    for i,txt in ipairs(arg) do
        text(txt, WIDTH/2, HEIGHT-(i*(fontSize()+(fontSize()/3))))
    end
end

The arg table does not seem to exist.

Edit: Solved… “that single one search result you missed before…”

function foo(...)
    -- get the number of args
    local n = select('#', ...)

    -- make a table out of the args
    local arg = {...}

    if n > 0 then
        print(arg[1])
    end
end

Yes, that changed in the latest version of Lua, now you have to make a table from the args