Decoration: Add height_min and height_max parameters
authorkwolekr <kwolekr@minetest.net>
Mon, 29 Dec 2014 03:37:27 +0000 (22:37 -0500)
committerkwolekr <kwolekr@minetest.net>
Mon, 29 Dec 2014 03:37:27 +0000 (22:37 -0500)
Also set default height_min/height_max to -31000 and 31000,
respectively, for ore and biomes

doc/lua_api.txt
src/mg_decoration.cpp
src/mg_decoration.h
src/script/lua_api/l_mapgen.cpp

index 7474c2bf41d9abbca93f20c6b3c60ca1b47bc417..1bfe0a0c22c53dbfe89dfe30f21a149f0e78377a 100644 (file)
@@ -2758,6 +2758,10 @@ Decoration definition (register_decoration)
     biomes = {"Oceanside", "Hills", "Plains"},
     ^ List of biomes in which this decoration occurs.  Occurs in all biomes if this is omitted,
     ^ and ignored if the Mapgen being used does not support biomes.
+    height_min = -31000
+    height_max = 31000
+    ^ Minimum and maximum y positions these decorations can be generated at.  This parameter refers to the
+    ^ y position of the decoration base, so the actual maximum height would be (height_max + size.Y).
 
     ----- Simple-type parameters
     decoration = "default:grass",
index 50e8fb05a65f31eec9a71f203445e84d55d33040..dec82a6380a08bd5f62f7b0e9dba91307097a8cb 100644 (file)
@@ -140,7 +140,8 @@ size_t Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax)
                                        mg->heightmap[mapindex] :
                                        mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
 
-                       if (y < nmin.Y || y > nmax.Y)
+                       if (y < nmin.Y     || y > nmax.Y ||
+                               y < height_min || y > height_max)
                                continue;
 
                        int height = getHeight();
index 910f1a581fc8ee620fc1a050284c4243a5994bc8..3c96611c7d579131e0d1bbefe7969032810107ca 100644 (file)
@@ -66,6 +66,8 @@ public:
        int mapseed;
        std::vector<content_t> c_place_on;
        s16 sidelen;
+       s16 height_min;
+       s16 height_max;
        float fill_ratio;
        NoiseParams np;
 
index a2e5d31d14f9c2770a809254b30ecc616954f904..cccbba5a8f19e86aa71d08c1efe0481be7924887 100644 (file)
@@ -423,14 +423,14 @@ int ModApiMapgen::l_register_biome(lua_State *L)
        Biome *b = bmgr->create(biometype);
 
        b->name            = getstringfield_default(L, index, "name", "");
-       b->depth_top       = getintfield_default(L, index, "depth_top",    1);
-       b->depth_filler    = getintfield_default(L, index, "depth_filler", 3);
-       b->height_shore    = getintfield_default(L, index, "height_shore", 3);
-       b->depth_water_top = getintfield_default(L, index, "depth_water_top", 0);
-       b->height_min      = getintfield_default(L, index, "height_min",   0);
-       b->height_max      = getintfield_default(L, index, "height_max",   0);
-       b->heat_point      = getfloatfield_default(L, index, "heat_point",     0.);
-       b->humidity_point  = getfloatfield_default(L, index, "humidity_point", 0.);
+       b->depth_top       = getintfield_default(L, index, "depth_top",          1);
+       b->depth_filler    = getintfield_default(L, index, "depth_filler",       3);
+       b->height_shore    = getintfield_default(L, index, "height_shore",       3);
+       b->depth_water_top = getintfield_default(L, index, "depth_water_top",    0);
+       b->height_min      = getintfield_default(L, index, "height_min",    -31000);
+       b->height_max      = getintfield_default(L, index, "height_max",     31000);
+       b->heat_point      = getfloatfield_default(L, index, "heat_point",     0.f);
+       b->humidity_point  = getfloatfield_default(L, index, "humidity_point", 0.f);
        b->flags           = 0; //reserved
 
        u32 id = bmgr->add(b);
@@ -501,6 +501,8 @@ int ModApiMapgen::l_register_decoration(lua_State *L)
 
        deco->name       = getstringfield_default(L, index, "name", "");
        deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02);
+       deco->height_min = getintfield_default(L, index, "height_min", 31000);
+       deco->height_max = getintfield_default(L, index, "height_max", -31000);
        deco->sidelen    = getintfield_default(L, index, "sidelen", 8);
        if (deco->sidelen <= 0) {
                errorstream << "register_decoration: sidelen must be "
@@ -660,8 +662,8 @@ int ModApiMapgen::l_register_ore(lua_State *L)
        ore->clust_scarcity = getintfield_default(L, index, "clust_scarcity", 1);
        ore->clust_num_ores = getintfield_default(L, index, "clust_num_ores", 1);
        ore->clust_size     = getintfield_default(L, index, "clust_size", 0);
-       ore->height_min     = getintfield_default(L, index, "height_min", 0);
-       ore->height_max     = getintfield_default(L, index, "height_max", 0);
+       ore->height_min     = getintfield_default(L, index, "height_min", -31000);
+       ore->height_max     = getintfield_default(L, index, "height_max", 31000);
        ore->nthresh        = getfloatfield_default(L, index, "noise_threshhold", 0);
        ore->noise          = NULL;
        ore->flags          = 0;