Comparison

core/modulemanager.lua @ 4151:a1ac8f064dcb

modulemanager: Added module.path to the plugin API to let plugins determine their load path.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 20 Feb 2011 20:06:38 +0500
parent 4135:9dfb3c0101b5
child 4337:a2ee8ab82dd9
comparison
equal deleted inserted replaced
4150:2894ca33ec45 4151:a1ac8f064dcb
115 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); 115 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
116 return nil, err; 116 return nil, err;
117 end 117 end
118 118
119 local _log = logger.init(host..":"..module_name); 119 local _log = logger.init(host..":"..module_name);
120 local api_instance = setmetatable({ name = module_name, host = host, config = config, _log = _log, log = function (self, ...) return _log(...); end }, { __index = api }); 120 local api_instance = setmetatable({ name = module_name, host = host, path = err, config = config, _log = _log, log = function (self, ...) return _log(...); end }, { __index = api });
121 121
122 local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); 122 local pluginenv = setmetatable({ module = api_instance }, { __index = _G });
123 api_instance.environment = pluginenv; 123 api_instance.environment = pluginenv;
124 124
125 setfenv(mod, pluginenv); 125 setfenv(mod, pluginenv);