diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-12-26 15:07:45 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-12-26 15:07:45 +0000 |
commit | a021cac4bd1000ecce951c576c31535f672773a5 (patch) | |
tree | 59edd18643ebb2d924f7fae74bebf90db02a26a2 /src | |
parent | updated TODO (diff) |
removed crapy require from module loader
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@72 ac14a137-c7f1-4531-abe0-07747231d213
Diffstat (limited to 'src')
-rw-r--r-- | src/module_list.lua | 12 |
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 |