Fix weirid sand layers caused by shore-thing of MGv7
[rocks.git] / sed.lua
blob702aa29d6baa5156ef8b31c2e9d6aae25df600b3
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(),
13 local beach_max=4
14 local lowland_max=21
15 local highland_max=60
16 local beach_min=-7
17 local lowland_min=5
18 local highland_min=22
21 -- Modify default grassland biome
22 local grassland=minetest.registered_biomes["default:grassland"] or
23 { -- default biome, if no biome mod is installed
24 name = "rocks:grassland",
25 node_top = "default:dirt_with_grass",
26 depth_top = 1,
27 y_min = lowland_min,
28 y_max = lowland_max,
29 heat_point = 50,
30 humidity_point = 50,
32 -- The biome layers are: dust, top, filler, stone
33 -- On beach: dust, shore_top, shore_filler, underwater
34 -- coastside: dust, top, filler, shore_filler, underwater, stone
35 if #minetest.registered_biomes > 1 then
36 minetest.log("error","Biomes registered before [rocks] discarded, please depend the mod on 'rocks' to fix this.")
37 -- can't just re-register them here, cause clear_biomes also clears decorations
38 end
39 minetest.clear_registered_biomes()
40 -- hook to inject our sedimentary stone to new biomes
41 local old_register_biome=minetest.register_biome
42 minetest.register_biome=function(def)
43 print("[rocks] register_biome .name="..def.name)
44 for n,v in pairs(def) do
45 --if type(v)~="table" then print(" "..n.."="..v) end
46 end
47 local cor=false -- was the biomeheight patched?
48 local tl=3 -- tolerance in determining biome type based on y_min/max values
49 local btype -- biome type (:string)
50 if (def.y_max>3000) and (def.y_min<=highland_min) then
51 -- correct upper boundary of registered bimes
52 if (def.y_min<10) and (def.y_min>0) then def.y_max=lowland_max cor=true end
53 if (def.y_min<30) and (def.y_min>10) then def.y_max=highland_max cor=true end
54 minetest.log("action","/rocks correcting upper bound on biome "..def.name.." to "..def.y_max)
55 end
56 -- actual detection code
57 if def.node_stone=="default:desert_stone" then btype="desert"
58 elseif (def.y_min>beach_min-tl) and (def.y_max<beach_max+tl) then btype="beach"
59 elseif (def.y_min>0) and (def.y_max<lowland_max+tl) then btype="lowland"
60 elseif (def.y_min>highland_min-tl) and (def.y_max<highland_max+tl) then btype="highland"
61 elseif (def.y_min<-3000) and (def.y_max<lowland_min+tl) then btype="ocean"
62 else minetest.log("error", "/rocks could not guess elevation type for biome "..def.name) end
63 -- patch the new biomes with our rocks
64 if btype=="lowland" then
65 def.node_filler="rocks:mudstone"
66 def.depth_filler=11
67 end
68 -- deactivate the added and removed shore-thing of MGv7
69 -- to fix weirid sand layers underground
70 if btype=="lowland" then -- fixme: does this affect beach/ocean too?
71 def.node_shore_top=def.node_top
72 def.node_shore_filler=def.node_filler
73 def.node_underwater=def.node_filler
74 end
75 -- and call the saved method to actually do the registration
76 old_register_biome(def)
77 end
78 --now register the default grassland
79 minetest.register_biome(grassland)
80 end
82 -- more biomes
83 -- todo: mountains, alps, volcanos
86 -- more rock defs
87 minetest.register_node( "rocks:limestone", {
88 description = S("Limestone"),
89 tiles = { "rocks_Limestone.png" },
90 is_ground_content = true, sounds = default.node_sound_stone_defaults(),
91 groups = {cracky=2},
95 local reg=function(name,param)
96 minetest.register_ore({
97 ore=name,
98 wherein= {
99 "rocks:mudstone",
101 ore_type = "scatter",
102 clust_scarcity = 1,
103 clust_size = 3,
104 clust_num_ores = 27,
105 y_min = -20,
106 y_max = 40,
107 noise_threshhold = param.treshold,
108 noise_params = {
109 offset=0, scale=1, octaves=3, persist=0.3,
110 spread={x=param.spread, y=param.height, z=param.spread},
111 seed=rocksl.GetNextSeed(),
116 -- this does register a new sedimentary vein.
117 rocks.register_sedimentary=reg
119 -- follows the only thing remaining from old ver :)
121 -- Sedimentary rock hardness and distribution
122 -- Rock Hard Distribution
123 --Breccia Weak Localized continental, folded
124 -->Claystone Weak Localized continental, folded, oceanic
125 --Conglomerate Weak Localized continental, folded
126 -->Limestone Medium Localized continental, folded; primary oceanic, hills
127 -->Coal - Large beds, twice as common in swamps
128 --reg("rocks:limestone", { spread=64, height=32, treshold=0.35 })
129 --reg("rocks:breccia", { spread=64, height=32, treshold=0.6 })
130 --reg("rocks:conglomerate", { spread=64, height=32, treshold=0.6 })
131 reg("default:stone_with_coal", { spread=64, height=14, treshold=0.60 })
132 reg("default:clay",{ spread=48, height=14, treshold=0.56 })
134 -- ~ Tomas Brod