1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-26 02:30:40 +01:00

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

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")