Skip to content

Commit f53bf3f

Browse files
committed
Added options to disable trees, plants, and landcover in Lua side
1 parent 7bd9a4b commit f53bf3f

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ Geo Mapgen can calculate automatically the positions of rivers with the elevatio
115115
Be aware that rivers calculation can be *very* slow (around 15 minutes for a 6000x6000 map).
116116

117117
## Configuration file
118-
A config file `heightmap.dat.conf` is generated in the world directory. It has the same syntax than `minetest.conf`, and currently supports 6 parameters:
118+
A config file `heightmap.dat.conf` is generated in the world directory. It has the same syntax than `minetest.conf`, and currently supports the following parameters:
119119
- `scale_x`, `scale_y`, scale_z`: set the scale for each axis. Size of objects is **divided** by this value.
120120
- `offset_x`, `offset_y`, `offset_z`: Offset of the world rectangle in nodes.
121+
- `rivers`: Enable or disable land cover. Default to `true`.
122+
- `landcover`: Enable or disable land cover.
123+
- `plants`: Enable or disable decorations (grass, ferns, trees etc.)
124+
- `trees`: Enable or disable schematic decorations (trees)
121125

122126
For example if you have generated a map with a resolution of 100 meters by pixel, and you set this in `heightmap.dat.conf`:
123127
```

init.lua

+22-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ local offset_x = tonumber(conf:get("offset_x")) or 0
1515
local offset_y = tonumber(conf:get("offset_y")) or 0
1616
local offset_z = tonumber(conf:get("offset_z")) or 0
1717

18+
local function get_bool(name)
19+
local v = conf:get_bool(name)
20+
if v == nil then
21+
return true -- Enable by default, disable only if explicitly set to false
22+
end
23+
return false
24+
end
25+
26+
local enable_rivers = get_bool("rivers")
27+
local enable_landcover = get_bool("landcover")
28+
local enable_trees = get_bool("trees")
29+
local enable_plants = get_bool("plants")
30+
31+
print(enable_rivers, enable_landcover, enable_trees, enable_plants)
32+
1833
local remove_delay = 10 -- Number of mapgen calls until a chunk is unloaded
1934

2035
local function parse(str, signed) -- little endian
@@ -133,11 +148,11 @@ for l=1, layer_count do
133148
elseif datatype == 1 then
134149
print("Rivermap enabled!")
135150
rivermap = layer
136-
rivers = true
151+
rivers = enable_rivers
137152
elseif datatype == 2 then
138153
print("Biomemap enabled!")
139154
biomemap = layer
140-
biomes = true
155+
biomes = enable_landcover
141156

142157
local biomes_by_name = dofile(modpath .. "/landcover.lua") -- Load biome descriptions
143158
local biomenames = meta:split(',', true)
@@ -235,11 +250,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
235250
top = biome.top
236251
nfiller = biome.filler_depth
237252
ntop = biome.top_depth
238-
if maxp.y >= h and not river_here then -- Generate decoration
253+
if enable_plants and maxp.y >= h and not river_here then -- Generate decoration
239254
local deco, is_schem = choose_deco(biome.decos)
240255
if deco then
241256
if is_schem then
242-
table.insert(schems_to_generate, {pos={x=x-2,y=h+1,z=z-2}, schem=deco}) -- Schem size is not known. Assuming that most of schematics have a size of 5, hardcode offset to 2. TODO: Change that when schematic flags will be available on minetest.place_schematic_on_vmanip
257+
if enable_trees then
258+
table.insert(schems_to_generate, {pos={x=x-2,y=h+1,z=z-2}, schem=deco}) -- Schem size is not known. Assuming that most of schematics have a size of 5, hardcode offset to 2. TODO: Change that when schematic flags will be available on minetest.place_schematic_on_vmanip
259+
end
243260
else
244261
node_deco = deco
245262
end
@@ -287,7 +304,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
287304
if river_here then
288305
data[ivm] = c_rwater
289306
ivm = ivm + ystride
290-
elseif node_deco and h >= 0 then
307+
elseif node_deco and h >= offset_y then
291308
data[ivm] = node_deco
292309
end
293310

0 commit comments

Comments
 (0)