Hi,
For a first game I had created descriptions of “levels” as .lua files ; in order to dynamically access the list of levels and avoid errors, I replaced “require” with a loadfile call:
local function loadLevel(level_index)
local path = system.pathForFile( "level/" .. level_index.. ".lua", system.ResourceDirectory );
local file = loadfile(path);
return file and file(); -- result of execution if exists
end
This works in the Simulator, but fails both on Android and HTML builds; documentation describes a related Android limitation in https://docs.coronalabs.com/api/library/system/ResourceDirectory.html , but I’m not sure what is the right workaround.
Will the above code work if I just change the extension of my data files to something else than .lua ? Or should I use a different file format (e.g. .json, but it would be more limited) ?
Or what is the proper way to support a collection of level configurations for my game that can be independently edited?
I appreciate your help and advice on how to best work around this problem…
-ivec