# HG changeset patch # User Matthew Wild # Date 1233195210 0 # Node ID fbfcf8c1c830975d99587214fc4bbbd4d5a402ca # Parent 1359492f45d745bed130deaa4d17ce977963bc5c configmanager: Add support for defining components diff -r 1359492f45d7 -r fbfcf8c1c830 core/configmanager.lua --- a/core/configmanager.lua Thu Jan 29 02:09:53 2009 +0000 +++ b/core/configmanager.lua Thu Jan 29 02:13:30 2009 +0000 @@ -107,7 +107,8 @@ parsers.lua = {}; function parsers.lua.load(data) local env; - env = setmetatable({ Host = true; host = true; }, { __index = function (t, k) + -- The ' = true' are needed so as not to set off __newindex when we assign the functions below + env = setmetatable({ Host = true; host = true; Component = true, component = true }, { __index = function (t, k) return rawget(_G, k) or function (settings_table) config[__currenthost or "*"][k] = settings_table; @@ -119,10 +120,21 @@ function env.Host(name) rawset(env, "__currenthost", name); + -- Needs at least one setting to logically exist :) set(name or "*", "core", "defined", true); end env.host = env.Host; + function env.Component(name) + return function (module) + set(name, "core", "component_module", module); + -- Don't load the global modules by default + set(name, "core", "modules_enable", false); + rawset(env, "__currenthost", name); + end + end + env.component = env.Component; + local chunk, err = loadstring(data); if not chunk then