summaryrefslogtreecommitdiff
path: root/src/module_list.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/module_list.lua')
-rw-r--r--src/module_list.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/module_list.lua b/src/module_list.lua
index eb12b1f..5ddb845 100644
--- a/src/module_list.lua
+++ b/src/module_list.lua
@@ -35,6 +35,7 @@ local defines = require("defines")
module_list = {}
module_list.classes = {}
+module_list.classes.__path = "./modules"
local mt = {}
function mt.__index(table, key)
local value = rawget(table, key)
@@ -42,11 +43,12 @@ function mt.__index(table, key)
log.printf(log.DEBUG, "load module class: %s", key)
- local old_path = package.path
- package.path = package.path .. ";./modules/?.lua"
- value = require(key)
- package.path = old_path
-
+ local filename = table.__path .. "/" .. key .. ".lua"
+ local chunk, err = loadfile(filename)
+ if (not chunk) then
+ error("failed to load module: " .. err)
+ end
+ value = chunk()
rawset(table, key, value)
return value
end