I’ve been using system.ResourceDirectory in order to read image files for a simpler way to add and remove image files from my game. This would allow me to change the images used for objects instead of hard coding in the path. However I’ve noticed that when I build for android that there is an exception that throws a runtime error if I try to do the same thing that works on iOS. I was wondering if there was a reasonable workaround. All I’m trying to do is take a folder and get an array of all of the files that start with a substring.
local function getBrickNames() local numberOfFiles = 0 local doc\_path = system.pathForFile( "/images", system.ResourceDirectory ) local filenames = {} for file in lfs.dir(doc\_path) do local filename = tostring(file) if ( string.starts( filename, "brick\_") ) then table.insert(filenames, filename ) end end return filenames end
Thank you,
Jarrod Lofy