If i use this code
-- some lua file
-- some code
local IMAGE_FILES = {"file1";"file2";"file3";"file4}
-- some code
function loadRes()
-- some code
-- load all images:
for i,v in ipairs(IMAGE_FILES) do
img[v] = love.graphics.newImage("data/img/"..v..".png")
end
-- some code
end
i have 2 problems!
- If i have/want to rename a file, i have to rename it in the IMAGE_FILES table,too. (If i forget to rename it in one place, either in the .lua-file or in the folder, i run into problems)
- If i need/want to add another file into the folder, i have to add its name to the variable,too.
For this reasons i want to load data(for example images, music, etc) out of a folder without having to let lua/love2d know the file names beforehand. In other words, is there a way to say to lua/love2d: load all files contained in this "data/img/" folder.
Secondly: Can you get the file type(file ending, like .png) with the solution for my first question?
I'm relatively new to lua and love2d, so i'd really appreciate any help. =)