!(function dirLookup(dir, extension, newFunc, sep, handle)
    sep = sep or "\n"
    handle = handle ~= nil and handle or function(varName, value)
        return varName .. ' = ' .. value
    end
    --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 .. '  -maxdepth 1 -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 .. '-- luacheck: ignore\n'
            assetCode = assetCode .. handle(varName, newFunc .. '("' .. file .. '")') .. sep
        end
    end
    return assetCode
end
function generatedFileWarning()
    -- Only in a function to make clear that THIS .lua2p is not the generated file!
    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'))
Logos = {
{ name = "Base", image = playdate.graphics.image.new("images/game/logos/Base.png") },

!!(dirLookup('images/game/logos -not -name "Base.png"', 'png', 'playdate.graphics.image.new', ",\n", function(varName, value)
    return '{ name = "' .. varName .. '", image = ' .. value .. ' }'
end))
}
