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