I have a set of configuration lua files that I keep in a specific directory of my project. I don’t want to have to manually require each one of these files every time I add a new one so I have a system that crawls through that directory and requires each lua file it finds. This works great in the simulator and on desktop builds but I am having trouble getting it to work with the HTML5 build. When my service crawls through the directory it just sees empty folders. Here is the code that normally accomplishes this task, it returns an array of paths to be used with require().
[lua]
local function getLuaFilesInFolder_R(path, cache)
local properPath = string.gsub(path, “[.]”, “/”)
local sysPath = system.pathForFile(properPath, system.ResourceDirectory)
for entry in lfs.dir(sysPath) do
local mode = lfs.attributes(sysPath … “/” … entry, “mode”)
if mode == “file” then
local name = string.match(entry, “(.*).lua”)
if name then
cache[#cache + 1] = path … “.” … name
end
elseif mode == “directory” then
if not string.match(entry, “^[.].*”) then
getLuaFilesInFolder_R(path … “.” … entry, cache)
end
end
end
return cache
end
local function getLuaFilesInFolder()
return getLuaFilesInFolder_R(“Config”, {})
end
[/lua]
Is there a way for this to work with the HTML5 build?
I’ve tested your sample. It works for me. Attached testcase. Here its output:
/config main.lua file
/config vvv directory
/config/vvv main.lua file
/config/vvv … directory
/config/vvv . directory
/config … directory
/config . directory
[“config.main”,“config.vvv.main”]
On what browser did you test ?
and what daily build did you use ?
Running your test with Corona 2018.3319 (2018.6.18) on Safari 11.1.1 (13605.2.8) I see the following output
[Log] SDL compiled version 2.0.5, linked version 2.0.5 (index-debug.html, line 144) [Log] Platform: emscripten / javascript / 1.0 / WebKit WebGL / OpenGL ES 2.0 (WebGL 1.0 (2.1 ATI-1.66.42) / 2018.3319 / en\_US | US | en\_US | en (index-debug.html, line 144) [Log] /config vvv directory (index-debug.html, line 144) [Log] /config/vvv .. directory (index-debug.html, line 144) [Log] /config/vvv . directory (index-debug.html, line 144) [Log] /config .. directory (index-debug.html, line 144) [Log] /config . directory (index-debug.html, line 144) [Log] []
and on Firefox 61.0.1 I see the following output
SDL compiled version 2.0.5, linked version 2.0.5 index-debug.html:144:13 Error: WebGL warning: Disallowing antialiased backbuffers due to blacklisting. 5ae5a1a2-7051-3a4f-b864-11a58665b33f:1:74008 Platform: emscripten / javascript / 1.0 / Mozilla / OpenGL ES 2.0 (WebGL 1.0) / 2018.3319 / en\_US | US | en\_US | en index-debug.html:144:13 /config vvv directory index-debug.html:144:13 /config/vvv .. directory index-debug.html:144:13 /config/vvv . directory index-debug.html:144:13 /config .. directory index-debug.html:144:13 /config . directory index-debug.html:144:13 []
In both cases the lua files are not present.
html5 builder excludes .lua files from html5 app, see builder log.
maybe rename that files ?
I’ve tested your sample. It works for me. Attached testcase. Here its output:
/config main.lua file
/config vvv directory
/config/vvv main.lua file
/config/vvv … directory
/config/vvv . directory
/config … directory
/config . directory
[“config.main”,“config.vvv.main”]
On what browser did you test ?
and what daily build did you use ?
Running your test with Corona 2018.3319 (2018.6.18) on Safari 11.1.1 (13605.2.8) I see the following output
[Log] SDL compiled version 2.0.5, linked version 2.0.5 (index-debug.html, line 144) [Log] Platform: emscripten / javascript / 1.0 / WebKit WebGL / OpenGL ES 2.0 (WebGL 1.0 (2.1 ATI-1.66.42) / 2018.3319 / en\_US | US | en\_US | en (index-debug.html, line 144) [Log] /config vvv directory (index-debug.html, line 144) [Log] /config/vvv .. directory (index-debug.html, line 144) [Log] /config/vvv . directory (index-debug.html, line 144) [Log] /config .. directory (index-debug.html, line 144) [Log] /config . directory (index-debug.html, line 144) [Log] []
and on Firefox 61.0.1 I see the following output
SDL compiled version 2.0.5, linked version 2.0.5 index-debug.html:144:13 Error: WebGL warning: Disallowing antialiased backbuffers due to blacklisting. 5ae5a1a2-7051-3a4f-b864-11a58665b33f:1:74008 Platform: emscripten / javascript / 1.0 / Mozilla / OpenGL ES 2.0 (WebGL 1.0) / 2018.3319 / en\_US | US | en\_US | en index-debug.html:144:13 /config vvv directory index-debug.html:144:13 /config/vvv .. directory index-debug.html:144:13 /config/vvv . directory index-debug.html:144:13 /config .. directory index-debug.html:144:13 /config . directory index-debug.html:144:13 []
In both cases the lua files are not present.
html5 builder excludes .lua files from html5 app, see builder log.
maybe rename that files ?