summaryrefslogtreecommitdiff
path: root/src/scriptapi.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-02 22:49:54 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-02 22:49:54 +0200
commit581f950e10b40f2af4ede56c3fa78f13eccb610b (patch)
tree5efd4bd3b304edb7e850cf2ffb8803439513385b /src/scriptapi.cpp
parent9344816bd6c40603729256b454e2f171902b02e5 (diff)
downloadminetest-581f950e10b40f2af4ede56c3fa78f13eccb610b.tar.gz
minetest-581f950e10b40f2af4ede56c3fa78f13eccb610b.tar.bz2
minetest-581f950e10b40f2af4ede56c3fa78f13eccb610b.zip
Fix script error reporting a bit
Diffstat (limited to 'src/scriptapi.cpp')
-rw-r--r--src/scriptapi.cpp20
1 files changed, 19 insertions, 1 deletions
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: "<<e.what()<<std::endl;
+ }
+
+ return success;
+}
+
void scriptapi_add_environment(lua_State *L, ServerEnvironment *env)
{
realitycheck(L);