Add nested lookup

This commit is contained in:
Talia 2022-12-25 14:50:10 +01:00
parent f3dab5753e
commit 1a739d3af2
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E

View file

@ -8,7 +8,13 @@ local config = {}
local __metatable = {} local __metatable = {}
function __metatable:__index(index) function __metatable:__index(index)
if type(index)~="string" then return nil end if type(index)~="string" then
return nil
end
local dot = index:find(".", 1, true)
if dot then
return self[index:sub(1, dot-1)][index:sub(dot+1)]
end
local path = self.__dir..'/'..index local path = self.__dir..'/'..index
local attributes = lfs.attributes(path) local attributes = lfs.attributes(path)
if attributes and attributes.mode=='directory' then if attributes and attributes.mode=='directory' then