New module loader properly halts when load-time error occurs in module.

This commit is contained in:
Anthony Zhang 2013-07-31 22:15:52 -04:00
parent b0bf52e9b6
commit 040282bbe6
1 changed files with 5 additions and 8 deletions

View File

@ -1,15 +1,12 @@
local path = minetest.get_modpath(minetest.get_current_modname()) local path = minetest.get_modpath(minetest.get_current_modname())
local loadmodule = function(path) local loadmodule = function(path)
local results = {pcall(function() local file = io.open(path)
return dofile(path) if not file then
end)} return
if results[1] then --successfully loaded module
table.remove(results, 1) --remove status indicator
return unpack(results) --return all results
else --load error
print(results[2])
end end
file:close()
return dofile(path)
end end
loadmodule(path .. "/manipulations.lua") loadmodule(path .. "/manipulations.lua")