Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index fb83917..9068257 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -476,6 +476,30 @@ int ModApiMapgen::l_get_biome_id(lua_State *L)
}
+// get_biome_at(pos)
+// returns the biome id at pos for mgv7
+int ModApiMapgen::l_get_biome_at(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+
+ v3s16 pos = check_v3s16(L, 1);
+
+ BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
+
+ if (!bmgr)
+ return 0;
+
+ Biome *biome = (Biome *)bmgr->getBiomeAtPoint(pos);
+
+ if (!biome || biome->index == OBJDEF_INVALID_INDEX)
+ return 0;
+
+ lua_pushinteger(L, biome->index);
+
+ return 1;
+}
+
+
// get_mapgen_object(objectname)
// returns the requested object used during map generation
int ModApiMapgen::l_get_mapgen_object(lua_State *L)
diff --git a/src/script/lua_api/l_mapgen.h b/src/script/lua_api/l_mapgen.h
index 9751c0d..ea361de 100644
--- a/src/script/lua_api/l_mapgen.h
+++ b/src/script/lua_api/l_mapgen.h
@@ -28,6 +28,10 @@ class ModApiMapgen : public ModApiBase {
// returns the biome id used in biomemap
static int l_get_biome_id(lua_State *L);
+ // get_biome_at(pos)
+ // returns the biome id at pos for mgv7
+ int ModApiMapgen::l_get_biome_at(lua_State *L);
+
// get_mapgen_object(objectname)
// returns the requested object used during map generation
static int l_get_mapgen_object(lua_State *L);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.