bugfix: only include files with numeric _prefixes_

A Lua gotcha: gmatch doesn't support '^'. I don't know why I was doing
that weird single-iteration loop anyway.
This commit is contained in:
Kartik K. Agaram 2023-04-20 23:42:36 -07:00
parent 0fc9fc5f22
commit b4a9f7f7f1
1 changed files with 4 additions and 4 deletions

View File

@ -49,8 +49,8 @@ function live.load_files_so_far()
if io.open(love.filesystem.getSaveDirectory()..'/0000-freewheeling-start') == nil then
print('copying all definitions from repo to save dir')
for _,filename in ipairs(love.filesystem.getDirectoryItems('')) do
for numeric_prefix, root in filename:gmatch('(%d+)-(.+)') do
-- only runs once
local numeric_prefix, root = filename:match('^(%d+)-(.+)')
if numeric_prefix then
local buf = love.filesystem.read(filename)
print('copying', filename)
love.filesystem.write(filename, buf)
@ -59,8 +59,8 @@ function live.load_files_so_far()
end
-- load files from save dir
for _,filename in ipairs(love.filesystem.getDirectoryItems('')) do
for numeric_prefix, root in filename:gmatch('(%d+)-(.+)') do
-- only runs once
local numeric_prefix, root = filename:match('^(%d+)-(.+)')
if numeric_prefix then
if tonumber(numeric_prefix) > 0 then -- skip 0000
Live.filename[root] = filename
table.insert(Live.filenames_to_load, filename)