This is an interesting question, but unfortunately I can only answer it partway.
For one thing, it is impossible to use Lua to change the default mapgen's cave generation parameters directly. However, you CAN change the minetest.conf file through Lua, using these settings (the #'s are comments):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
# Perlin noise attributes for different map generation parameters
# Offset, scale, spread factor, seed offset, number of octaves, persistence
#mgv6_np_cave = 6, 6, (250, 250, 250), 34329, 3, 0.50
So by editing the values for mgv6_np_cave, you can affect how the caves are generated. Here, I believe the values you would be interested the most in are the 2nd (scale = 6), 3rd (spread = (250,250,250)), 5th (octaves = 3), and 6th (persistance = 0.5).
The scale controls the "volume" of the noise that makes the caves: a larger value makes larger caves, which are somewhat farther apart because the gaps are also amplified.
The spread has similar effects (paramat could tell you better), but the upshot of changing THESE values is that you can "squash" or "stretch" the structure of the caves by say, cutting the 2nd (y) value in half to make the caves shorter in height.
The octaves control how many times the noise calculation is performed on the terrain. A higher value smooths things out in the long run while also slightly increasing the maximum and minimum values that can be reached. This can greatly affect structure and even frequency of caves.
Finally, the persist is directly tied to the octaves: it is the value that the base is multiplied by for each octave. 0.5 is default, 0.6 is a slightly rougher value used in the industry, and 0.67 is a favorite among minetest modders because of the extreme terrains it makes (look at watershed!).
Alternatively, you can tweak the C++ code directly and recompile it yourself (not recommended), or make a lua on_mapgen mod to add even more caves. If you choose that route, look at paramat's subterrain mod for a simple example or my CaveRealms for a detailed example.
Hope this helps!
Nam ex spatio, omnes res venire possunt.
Why let the ground limit you when you can reach for the sky?
Back to college now, yay for sophomore year schedules. :P