summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mapgen.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-04-07 23:04:48 -0400
committerkwolekr <kwolekr@minetest.net>2015-04-08 00:28:56 -0400
commit0df736173e60df06a7a7162c285b9c5731a07c20 (patch)
tree4ed5c22380dd70213b820544b1e75ae8ca1ad573 /src/script/lua_api/l_mapgen.cpp
parent5132908f4b834c344d19dcb20939cda175fc82a4 (diff)
downloadminetest-0df736173e60df06a7a7162c285b9c5731a07c20.tar.gz
minetest-0df736173e60df06a7a7162c285b9c5731a07c20.tar.bz2
minetest-0df736173e60df06a7a7162c285b9c5731a07c20.zip
Schematics: Prepend mod path to relative schematic filepaths
Diffstat (limited to 'src/script/lua_api/l_mapgen.cpp')
-rw-r--r--src/script/lua_api/l_mapgen.cpp8
1 files changed, 7 insertions, 1 deletions
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;