gracefully handle a non-existent filename at the commandline

This commit is contained in:
Kartik K. Agaram 2022-05-16 18:46:27 -07:00
parent 662096d98f
commit 753318f664
1 changed files with 5 additions and 2 deletions

View File

@ -78,7 +78,7 @@ function love.draw()
love.graphics.setColor(1, 1, 1)
love.graphics.rectangle('fill', 0, 0, screenw-1, screenh-1)
love.graphics.setColor(0, 0, 0)
local text
local text = love.graphics.newText(love.graphics.getFont(), '')
local y = 0
for i,line in ipairs(lines) do
y = y+25
@ -814,7 +814,7 @@ function math.dist(x1,y1, x2,y2) return ((x2-x1)^2+(y2-y1)^2)^0.5 end
function load_from_disk(filename)
local infile = io.open(filename)
local result = load_from_file(infile)
infile:close()
if infile then infile:close() end
return result
end
@ -832,6 +832,9 @@ function load_from_file(infile)
end
end
end
if #result == 0 then
table.insert(result, '')
end
return result
end