From 581f950e10b40f2af4ede56c3fa78f13eccb610b Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 2 Dec 2011 22:49:54 +0200 Subject: Fix script error reporting a bit --- src/scriptapi.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/scriptapi.cpp') diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index cb26fa472..db6b7e86e 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -1101,7 +1101,10 @@ static int l_register_craft(lua_State *L) width = colcount; } else { if(colcount != width){ - script_error(L, "error: %s\n", "Invalid crafting recipe"); + std::string error; + error += "Invalid crafting recipe (output=\"" + + output + "\")"; + throw LuaError(error); } } // removes value, keeps key for next iteration @@ -2469,6 +2472,21 @@ void scriptapi_export(lua_State *L, Server *server) ObjectRef::Register(L); } +bool scriptapi_loadmod(lua_State *L, const std::string &scriptpath, + const std::string &modname) +{ + bool success = false; + + try{ + success = script_load(L, scriptpath.c_str()); + } + catch(LuaError &e){ + errorstream<<"Error loading mod: "<