tween.delay() vs draw()

in the 50 Lines thread, @SkyTheCoder posted a program that didn’t have a draw() function. instead it had tween.delay(1, loop), where loop() was the function that drew on the screen. Is this a possible work-around to control framerate? i’m very curious about this. Here’s his program:

-- 50 Lines
function setup()
    cost, incomePerHouse, Money, Houses = 50, 10, 0, "|#" .. (" "):rep(32) .. "|"
    updateParams()
    loop()
end
function buy()
    if Money >= cost and houseC < 33 then
        cost, Money, Houses = cost + 40, Money - cost, "|" .. Houses:sub(2, houseC + 1) .. "#" .. (" "):rep(32 - houseC) .. "|"
        updateParams()
    end
end
function upgrade()
    if Money >= cost then
        Money, incomePerHouse, cost = Money - cost, incomePerHouse + 5, cost + 30
        updateParams()
    end
end
function updateParams()
    parameter.clear()
    parameter.action("Buy House ($" .. cost .. ")", buy)
    parameter.action("Upgrade Income ($" .. cost .. ")", upgrade)
end
function loop()
    output.clear()
    houseC = 0
    for i in Houses:gmatch("#") do
        houseC = houseC + 1
    end
    for i = 1, houseC do
        Money = Money + incomePerHouse
    end
    print("House Tycoon\
\
$$$$    " .. string.format("%19.0f", Money) .. "    $$$$\
\
Houses:\
" .. Houses .. "\
\
Income: " .. houseC * incomePerHouse .. "\
\
Income per house: " .. incomePerHouse)
    tween.delay(1, loop)
end

Yes. The draw function is not required. I used a tween.delay loop there. Technically, the tween stuff IS updating right before draw is called, but if you use delays, it essentially goes for the closest match to whatever delay you set and can skip all the frames in between. This could be used as frame rate control, actually, but note, I wasn’t the first to think of this, I think I remember seeing it other places before.

The documentation for that function didn’t describe what unit the first parameter was in. Is it in milliseconds or seconds? seems like it would be seconds, judging by how you used it.

it’s seconds, but don’t expect it to give you finer grained control over timing than draw. It wasn’t designed for that.