summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mg_ore.cpp12
-rw-r--r--src/mg_ore.h4
-rw-r--r--src/script/lua_api/l_mapgen.cpp13
3 files changed, 23 insertions, 6 deletions
diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp
index 0d0f74bf5..f5d312ba2 100644
--- a/src/mg_ore.cpp
+++ b/src/mg_ore.cpp
@@ -176,8 +176,8 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
PseudoRandom pr(blockseed + 4234);
MapNode n_ore(c_ore, 0, ore_param2);
- int max_height = clust_size;
- int y_start = pr.range(nmin.Y, nmax.Y - max_height);
+ u16 max_height = column_height_max;
+ int y_start = pr.range(nmin.Y + max_height, nmax.Y - max_height);
if (!noise) {
int sx = nmax.X - nmin.X + 1;
@@ -200,10 +200,12 @@ void OreSheet::generate(MMVManip *vm, int mapseed, u32 blockseed,
continue;
}
- int height = max_height * (1. / pr.range(1, 3));
- int y0 = y_start + np.scale * noiseval; //pr.range(1, 3) - 1;
+ u16 height = pr.range(column_height_min, column_height_max);
+ int ymidpoint = y_start + noiseval;
+ int y0 = ymidpoint - height * (1 - column_midpoint_factor);
int y1 = y0 + height;
- for (int y = y0; y != y1; y++) {
+
+ for (int y = y0; y < y1; y++) {
u32 i = vm->m_area.index(x, y, z);
if (!vm->m_area.contains(i))
continue;
diff --git a/src/mg_ore.h b/src/mg_ore.h
index ffe8cfe50..db204437e 100644
--- a/src/mg_ore.h
+++ b/src/mg_ore.h
@@ -87,6 +87,10 @@ class OreSheet : public Ore {
public:
static const bool NEEDS_NOISE = true;
+ u16 column_height_min;
+ u16 column_height_max;
+ float column_midpoint_factor;
+
virtual void generate(MMVManip *vm, int mapseed, u32 blockseed,
v3s16 nmin, v3s16 nmax, u8 *biomemap);
};
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp
index d30b68054..9050816bb 100644
--- a/src/script/lua_api/l_mapgen.cpp
+++ b/src/script/lua_api/l_mapgen.cpp
@@ -937,8 +937,19 @@ int ModApiMapgen::l_register_ore(lua_State *L)
}
lua_pop(L, 1);
- if (oretype == ORE_VEIN) {
+ //// Get type-specific parameters
+ if (oretype == ORE_SHEET) {
+ OreSheet *oresheet = (OreSheet *)ore;
+
+ oresheet->column_height_min = getintfield_default(L, index,
+ "column_height_min", 1);
+ oresheet->column_height_max = getintfield_default(L, index,
+ "column_height_max", ore->clust_size);
+ oresheet->column_midpoint_factor = getfloatfield_default(L, index,
+ "column_midpoint_factor", 0.5f);
+ } else if (oretype == ORE_VEIN) {
OreVein *orevein = (OreVein *)ore;
+
orevein->random_factor = getfloatfield_default(L, index,
"random_factor", 1.f);
}