Experiments with layers.
[rocks.git] / rocks / sed.lua
blob157f18c610f9143d5855e1ee40862063db72caa5
1 --
2 -- Sedimentary Layer
3 --
5 -- Mudstone Sed soft Ocean, beach, river, glaciers
6 minetest.register_node( "rocks:mudstone", {
7 description = S("Mudstone"),
8 tiles = { "rocks_Mudstone.png" },
9 groups = {cracky=1, crumbly=3},
10 is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
12 -- more rock defs
13 minetest.register_node( "rocks:limestone", {
14 description = S("Limestone"),
15 tiles = { "rocks_Limestone.png" },
16 is_ground_content = true, sounds = default.node_sound_stone_defaults(),
17 groups = {cracky=2},
19 minetest.register_node( "rocks:laterite", {
20 description = S("Laterite clay"),
21 tiles = { "rocks_laterite.png" },
22 is_ground_content = true, sounds = default.node_sound_dirt_defaults(),
23 groups = {crumbly=3},
26 local beach_max=4
27 local lowland_max=27
28 local highland_max=200
29 local beach_min=-7
30 local lowland_min=5
31 local highland_min=28
34 -- Modify default grassland biome
35 local grassland=minetest.registered_biomes["default:grassland"] or
36 { -- default biome, if no biome mod is installed
37 name = "rocks:grassland",
38 node_top = "air",
39 depth_top = 0,
40 depth_filler=0,
41 y_min = lowland_min,
42 y_max = lowland_max,
43 heat_point = 50,
44 humidity_point = 50,
46 local mountains={ -- default mountain biome
47 name = "rocks:mountain",
48 node_top = "default:dirt_with_grass",
49 depth_top = 1,
50 node_filler = "default:dirt",
51 depth_filler = 2,
52 node_stone = nil,
53 y_min = highland_min,
54 y_max = highland_max,
55 heat_point = 50,
56 humidity_point = 50,
58 -- The biome layers are: dust, top, filler, stone
59 -- On beach: dust, shore_top, shore_filler, underwater
60 -- coastside: dust, top, filler, shore_filler, underwater, stone
61 if #minetest.registered_biomes > 1 then
62 minetest.log("error","Biomes registered before [rocks] discarded, please depend the mod on 'rocks' to fix this.")
63 -- can't just re-register them here, cause clear_biomes also clears decorations
64 end
65 minetest.clear_registered_biomes()
66 -- hook to inject our sedimentary stone to new biomes
67 local old_register_biome=minetest.register_biome
68 minetest.register_biome=function(def)
69 --print("[rocks] register_biome .name="..def.name)
70 for n,v in pairs(def) do
71 --if type(v)~="table" then print(" "..n.."="..v) end
72 end
73 local cor=false -- was the biomeheight patched?
74 local tl=3 -- tolerance in determining biome type based on y_min/max values
75 local btype -- biome type (:string)
76 if (def.y_max>3000) and (def.y_min<=highland_min) then
77 -- correct upper boundary of registered bimes
78 if (def.y_min<10) and (def.y_min>0) then def.y_max=lowland_max cor=true end
79 if (def.y_min<30) and (def.y_min>10) then def.y_max=highland_max cor=true end
80 minetest.log("action","/rocks correcting upper bound on biome "..def.name.." to "..def.y_max)
81 end
82 -- actual detection code
83 if def.node_stone=="default:desert_stone" then btype="desert"
84 elseif (def.y_min>beach_min-tl) and (def.y_max<beach_max+tl) then btype="beach"
85 elseif (def.y_min>0) and (def.y_max<lowland_max+tl) then btype="lowland"
86 elseif (def.y_min>highland_min-tl) and (def.y_max<highland_max+tl) then btype="highland"
87 elseif (def.y_min<-3000) and (def.y_max<lowland_min+tl) then btype="ocean"
88 else minetest.log("error", "/rocks could not guess elevation type for biome "..def.name) end
89 rocksl.print("register_biome .name="..def.name.." -> btype="..btype)
90 -- patch the new biomes with our rocks
91 if btype=="lowland" then
92 --def.node_filler="rocks:mudstone"
93 --def.depth_filler=11
94 --def.node_stone="rocks:granite"
95 if (def.humidity_point>80) and (def.heat_point>80) then
96 --def.node_filler="rocks:laterite"
97 end
98 elseif btype=="highland" then
99 def.node_filler="rocks:limestone"
100 def.node_stone="rocks:limestone"
101 def.depth_filler=15
102 elseif btype=="beach" then
103 def.node_stone="rocks:granite"
104 def.y_min=beach_min
105 if def.heat_point<50 then
106 def.node_top="default:gravel"
107 def.node_filler="default:gravel"
108 def.depth_filler=2
109 elseif def.node_top=="default:sand" then
110 if def.depth_top<2 then def.depth_top=3 end
111 def.node_filler="default:sandstone"
112 def.depth_filler=5
114 elseif btype=="ocean" then
115 def.node_stone="rocks:basalt"
116 def.node_top="default:gravel"
117 def.node_filler="rocks:limestone"
119 do -- deactivate the added and removed shore-thing of MGv7
120 -- to fix weirid sand layers underground
121 def.node_shore_top=def.node_top
122 def.node_shore_filler=def.node_filler
123 def.node_underwater=def.node_top
125 -- and call the saved method to actually do the registration
126 old_register_biome(def)
128 --now register the default grassland
129 minetest.register_biome(grassland)
130 -- create a default mountain biome...
131 minetest.register_biome(mountains)
132 -- hook the clear callback (fix biomesdev)
133 local old_clear=minetest.clear_registered_biomes
134 minetest.clear_registered_biomes=function()
135 old_clear()
136 minetest.log("action","/rocks re-registering default mountain biome!")
137 minetest.register_biome(mountains)
141 -- more biomes
142 -- todo: mountains, alps, volcanos
146 local reg=function(name,param)
147 minetest.register_ore({
148 ore=name,
149 wherein= {
150 "rocks:mudstone",
152 ore_type = "scatter",
153 clust_scarcity = 8^3,
154 clust_size = 10,
155 clust_num_ores = 10^3,
156 y_min = -20,
157 y_max = 40,
158 noise_threshhold = param.treshold,
159 noise_params = {
160 offset=0, scale=1, octaves=1, persist=0.3,
161 spread={x=param.spread, y=param.height, z=param.spread},
162 seed=rocksl.GetNextSeed(),
167 -- this does register a new sedimentary vein.
168 rocks.register_sedimentary=reg
170 -- follows the only thing remaining from old ver :)
172 -- Sedimentary rock hardness and distribution
173 -- Rock Hard Distribution
174 --Breccia Weak Localized continental, folded
175 -->Claystone Weak Localized continental, folded, oceanic
176 --Conglomerate Weak Localized continental, folded
177 -->Limestone Medium Localized continental, folded; primary oceanic, hills
178 -->Coal - Large beds, twice as common in swamps
179 --reg("rocks:limestone", { spread=64, height=32, treshold=0.35 })
180 --reg("rocks:breccia", { spread=64, height=32, treshold=0.6 })
181 --reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 })
182 --reg("default:stone_with_coal", { spread=64, height=14, treshold=0.58 })
183 --reg("default:clay",{ spread=48, height=14, treshold=0.55 })
185 -- ~ Tomas Brod