summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mapgen.cpp
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2018-03-09 23:16:23 +0000
committerparamat <mat.gregory@virginmedia.com>2018-03-11 23:06:17 +0000
commit7ad6cdd09b55197a25f9af34ad807813eab6247b (patch)
tree08ee5c4a7fe31172eee7459e31ad97c3fb4c656d /src/script/lua_api/l_mapgen.cpp
parenta09a994417a6971313296aa31ef9090636058822 (diff)
downloadminetest-7ad6cdd09b55197a25f9af34ad807813eab6247b.tar.gz
minetest-7ad6cdd09b55197a25f9af34ad807813eab6247b.tar.bz2
minetest-7ad6cdd09b55197a25f9af34ad807813eab6247b.zip
Biome API: Add 'get_biome_name(biome_id)' API
Change name of default biome to a more suitable lowercase 'default'.
Diffstat (limited to 'src/script/lua_api/l_mapgen.cpp')
-rw-r--r--src/script/lua_api/l_mapgen.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index f5c76ec6e..263273cc3 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -476,12 +476,10 @@ int ModApiMapgen::l_get_biome_id(lua_State *L)
return 0;
BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
-
if (!bmgr)
return 0;
Biome *biome = (Biome *)bmgr->getByName(biome_str);
-
if (!biome || biome->index == OBJDEF_INVALID_INDEX)
return 0;
@@ -491,6 +489,25 @@ int ModApiMapgen::l_get_biome_id(lua_State *L)
}
+// get_biome_name(biome_id)
+// returns the biome name string
+int ModApiMapgen::l_get_biome_name(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+
+ int biome_id = luaL_checkinteger(L, 1);
+
+ BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr;
+ if (!bmgr)
+ return 0;
+
+ Biome *b = (Biome *)bmgr->getRaw(biome_id);
+ lua_pushstring(L, b->name.c_str());
+
+ return 1;
+}
+
+
// get_heat(pos)
// returns the heat at the position
int ModApiMapgen::l_get_heat(lua_State *L)
@@ -1731,6 +1748,7 @@ int ModApiMapgen::l_serialize_schematic(lua_State *L)
void ModApiMapgen::Initialize(lua_State *L, int top)
{
API_FCT(get_biome_id);
+ API_FCT(get_biome_name);
API_FCT(get_heat);
API_FCT(get_humidity);
API_FCT(get_biome_data);