From 0df736173e60df06a7a7162c285b9c5731a07c20 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Tue, 7 Apr 2015 23:04:48 -0400 Subject: Schematics: Prepend mod path to relative schematic filepaths --- src/script/lua_api/l_mapgen.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/script/lua_api/l_mapgen.cpp') diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index cbe3610c8..d08cfea8a 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mg_schematic.h" #include "mapgen_v5.h" #include "mapgen_v7.h" +#include "filesys.h" #include "settings.h" #include "log.h" @@ -142,7 +143,12 @@ Schematic *load_schematic(lua_State *L, int index, return NULL; } else if (lua_isstring(L, index)) { schem = SchematicManager::create(SCHEMATIC_NORMAL); - if (!schem->loadSchematicFromFile(lua_tostring(L, index), + + std::string filepath = lua_tostring(L, index); + if (!fs::IsPathAbsolute(filepath)) + filepath = ModApiBase::getCurrentModPath(L) + DIR_DELIM + filepath; + + if (!schem->loadSchematicFromFile(filepath.c_str(), schemmgr->getNodeDef(), replace_names)) { delete schem; return NULL; -- cgit v1.2.3