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