From 1a739d3af24b285a76f6c28291eaa55f87e2a8b2 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Sun, 25 Dec 2022 14:50:10 +0100 Subject: [PATCH] Add nested lookup --- glass.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/glass.lua b/glass.lua index 81a29ba..0838b47 100644 --- a/glass.lua +++ b/glass.lua @@ -8,7 +8,13 @@ local config = {} local __metatable = {} 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 attributes = lfs.attributes(path) if attributes and attributes.mode=='directory' then