From c2d0d411d4e5b3b701da89d8f29cd37ea1a64bf1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 8 Dec 2023 13:36:51 +0000 Subject: configmanager: Allow referencing previously-set options in the config file --- core/configmanager.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core') diff --git a/core/configmanager.lua b/core/configmanager.lua index 951f61fd..9a66ad13 100644 --- a/core/configmanager.lua +++ b/core/configmanager.lua @@ -62,6 +62,16 @@ local function set(config_table, host, key, value) return false; end +local function rawget_option(config_table, host, key) + if host and key then + local hostconfig = rawget(config_table, host); + if not hostconfig then + return nil; + end + return rawget(hostconfig, key); + end +end + function _M.set(host, key, value) return set(config, host, key, value); end @@ -119,6 +129,10 @@ do if k:match("^ENV_") then return os.getenv(k:sub(5)); end + local val = rawget_option(config_table, env.__currenthost or "*", k); + if val ~= nil then + return val; + end return rawget(_G, k); end, __newindex = function (_, k, v) -- cgit v1.2.3