!(function dirLookup(dir, extension, newFunc)
    --Open directory look for files, save data in p. By giving '-type f' as parameter, it returns all files.
    local p = io.popen('find src/' .. dir .. ' -type f')

    local assetCode = ""
    --Loop through all files
    for file in p:lines() do
        if file:find(extension) then
            local varName = file:gsub(".*/(.*)." .. extension, "%1")
            file = file:gsub("src/", "")
            assetCode = assetCode .. '--selene: allow(unused_variable)\n'
            assetCode = assetCode .. '--selene: allow(unscoped_variables)\n'
            assetCode = assetCode .. varName .. ' = ' .. newFunc .. '("' .. file .. '")\n'
        end
    end
    return assetCode
end
function generatedFileWarning()
    return "-- GENERATED FILE - DO NOT EDIT\n-- Instead, edit the source file directly: assets.lua2p."
end) !!(generatedFileWarning())

!!(dirLookup('images/game', 'png', 'playdate.graphics.image.new'))
!!(dirLookup('sounds', 'wav', 'playdate.sound.sampleplayer.new'))
!!(dirLookup('music', 'wav', 'playdate.sound.sampleplayer.new'))
