mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Biome API: Add 'get_biome_name(biome_id)' API
Change name of default biome to a more suitable lowercase 'default'.
This commit is contained in:
@@ -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);
|
||||
|
@@ -28,6 +28,10 @@ private:
|
||||
// returns the biome id as used in biomemap and returned by 'get_biome_data()'
|
||||
static int l_get_biome_id(lua_State *L);
|
||||
|
||||
// get_biome_name(biome_id)
|
||||
// returns the biome name string
|
||||
static int l_get_biome_name(lua_State *L);
|
||||
|
||||
// get_heat(pos)
|
||||
// returns the heat at the position
|
||||
static int l_get_heat(lua_State *L);
|
||||
|
Reference in New Issue
Block a user