Skip to content

Commit 650d706

Browse files
committedMar 24, 2013
Use minetest.register_ore() in minimal
1 parent 0e07a71 commit 650d706

File tree

1 file changed

+64
-54
lines changed

1 file changed

+64
-54
lines changed
 

‎games/minimal/mods/default/mapgen.lua

+64-54
Original file line numberDiff line numberDiff line change
@@ -27,64 +27,74 @@ minetest.register_alias("mapgen_mese", "default:mese")
2727
-- Ore generation
2828
--
2929

30-
local function generate_ore(name, wherein, minp, maxp, seed, chunks_per_volume, ore_per_chunk, height_min, height_max, param2)
31-
if maxp.y < height_min or minp.y > height_max then
32-
return
33-
end
34-
local y_min = math.max(minp.y, height_min)
35-
local y_max = math.min(maxp.y, height_max)
36-
local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
37-
local pr = PseudoRandom(seed)
38-
local num_chunks = math.floor(chunks_per_volume * volume)
39-
local chunk_size = 3
40-
if ore_per_chunk <= 4 then
41-
chunk_size = 2
42-
end
43-
local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
44-
--print("generate_ore num_chunks: "..dump(num_chunks))
45-
for i=1,num_chunks do
46-
local y0 = pr:next(y_min, y_max-chunk_size+1)
47-
if y0 >= height_min and y0 <= height_max then
48-
local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
49-
local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
50-
local p0 = {x=x0, y=y0, z=z0}
51-
for x1=0,chunk_size-1 do
52-
for y1=0,chunk_size-1 do
53-
for z1=0,chunk_size-1 do
54-
if pr:next(1,inverse_chance) == 1 then
55-
local x2 = x0+x1
56-
local y2 = y0+y1
57-
local z2 = z0+z1
58-
local p2 = {x=x2, y=y2, z=z2}
59-
if minetest.env:get_node(p2).name == wherein then
60-
minetest.env:set_node(p2, {name=name, param2=param2})
61-
end
62-
end
63-
end
64-
end
65-
end
66-
end
67-
end
68-
--print("generate_ore done")
69-
end
30+
minetest.register_ore({
31+
ore_type = "scatter",
32+
ore = "default:stone_with_coal",
33+
wherein = "default:stone",
34+
clust_scarcity = 8*8*8,
35+
clust_num_ores = 5,
36+
clust_size = 3,
37+
height_min = -31000,
38+
height_max = 64,
39+
})
7040

71-
minetest.register_on_generated(function(minp, maxp, seed)
72-
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed, 1/8/8/8, 5, -31000, 64 )
73-
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+1, 1/16/16/16, 5, -5, 7 )
74-
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+2, 1/12/12/12, 5, -16, -5 )
75-
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+3, 1/9/9/9, 5, -31000, -17 )
41+
minetest.register_ore({
42+
ore_type = "scatter",
43+
ore = "default:stone_with_iron",
44+
wherein = "default:stone",
45+
clust_scarcity = 16*16*16,
46+
clust_num_ores = 5,
47+
clust_size = 3,
48+
height_min = -5,
49+
height_max = 7,
50+
})
7651

77-
generate_ore("default:stone_with_coal", "default:stone", minp, maxp, seed+4, 1/8/8/8, 5, 200, 31000 ) -- for float islands and far scaled mountains
78-
generate_ore("default:stone_with_iron", "default:stone", minp, maxp, seed+5, 1/9/9/9, 5, 200, 31000 )
52+
minetest.register_ore({
53+
ore_type = "scatter",
54+
ore = "default:stone_with_iron",
55+
wherein = "default:stone",
56+
clust_scarcity = 12*12*12,
57+
clust_num_ores = 5,
58+
clust_size = 3,
59+
height_min = -16,
60+
height_max = -5,
61+
})
7962

80-
if minetest.setting_getbool("underground_springs") then
81-
generate_ore("default:water_source", "default:stone", minp, maxp, seed+4, 1/24/24/24, 12, -100, -11, 128)
82-
generate_ore("default:water_source", "default:stone", minp, maxp, seed+5, 1/28/28/28, 8, -10000, -101, 128)
83-
generate_ore("default:lava_source", "default:stone", minp, maxp, seed+6, 1/38/38/38, 6, -500, -101, 128)
84-
generate_ore("default:lava_source", "default:stone", minp, maxp, seed+7, 1/30/30/30, 16, -5000, -501, 128)
85-
generate_ore("default:lava_source", "default:stone", minp, maxp, seed+8, 1/24/24/24, 20, -31000, -5001, 128)
86-
end
63+
minetest.register_ore({
64+
ore_type = "scatter",
65+
ore = "default:stone_with_iron",
66+
wherein = "default:stone",
67+
clust_scarcity = 9*9*9,
68+
clust_num_ores = 5,
69+
clust_size = 3,
70+
height_min = -31000,
71+
height_max = -17,
72+
})
8773

74+
-- for float islands and far scaled
75+
minetest.register_ore({
76+
ore_type = "scatter",
77+
ore = "default:stone_with_coal",
78+
wherein = "default:stone",
79+
clust_scarcity = 8*8*8,
80+
clust_num_ores = 5,
81+
clust_size = 3,
82+
height_min = 200,
83+
height_max = 31000,
84+
})
85+
86+
minetest.register_ore({
87+
ore_type = "scatter",
88+
ore = "default:stone_with_iron",
89+
wherein = "default:stone",
90+
clust_scarcity = 9*9*9,
91+
clust_num_ores = 5,
92+
clust_size = 3,
93+
height_min = 200,
94+
height_max = 31000,
95+
})
96+
97+
minetest.register_on_generated(function(minp, maxp, seed)
8898
-- Generate clay
8999
if maxp.y >= 2 and minp.y <= 0 then
90100
-- Assume X and Z lengths are equal

0 commit comments

Comments
 (0)
Please sign in to comment.