2 -- Aliases for map generator outputs
6 minetest.register_alias("mapgen_stone", "default:stone")
7 minetest.register_alias("mapgen_dirt", "default:dirt")
8 minetest.register_alias("mapgen_dirt_with_grass", "default:dirt_with_grass")
9 minetest.register_alias("mapgen_sand", "default:sand")
10 minetest.register_alias("mapgen_water_source", "default:water_source")
11 minetest.register_alias("mapgen_lava_source", "default:lava_source")
12 minetest.register_alias("mapgen_gravel", "default:gravel")
13 minetest.register_alias("mapgen_desert_stone", "default:desert_stone")
14 minetest.register_alias("mapgen_desert_sand", "default:desert_sand")
15 minetest.register_alias("mapgen_dirt_with_snow", "default:dirt_with_snow")
16 minetest.register_alias("mapgen_snow", "default:snow")
17 minetest.register_alias("mapgen_snowblock", "default:snowblock")
18 minetest.register_alias("mapgen_ice", "default:ice")
20 minetest.register_alias("mapgen_tree", "default:tree")
21 minetest.register_alias("mapgen_leaves", "default:leaves")
22 minetest.register_alias("mapgen_apple", "default:apple")
23 minetest.register_alias("mapgen_jungletree", "default:jungletree")
24 minetest.register_alias("mapgen_jungleleaves", "default:jungleleaves")
25 minetest.register_alias("mapgen_junglegrass", "default:junglegrass")
26 minetest.register_alias("mapgen_pinetree", "default:pinetree")
27 minetest.register_alias("mapgen_pine_needles", "default:pine_needles")
29 minetest.register_alias("mapgen_cobble", "default:cobble")
30 minetest.register_alias("mapgen_stair_cobble", "stairs:stair_cobble")
31 minetest.register_alias("mapgen_mossycobble", "default:mossycobble")
39 -- Blob ore first to avoid other ores inside blobs
41 function default.register_ores()
42 minetest.register_ore({
45 wherein = {"default:sand"},
46 clust_scarcity = 24*24*24,
54 spread={x=5, y=5, z=5},
61 minetest.register_ore({
64 wherein = {"default:stone"},
65 clust_scarcity = 24*24*24,
73 spread={x=5, y=5, z=5},
80 minetest.register_ore({
83 wherein = {"default:stone"},
84 clust_scarcity = 24*24*24,
92 spread={x=5, y=5, z=5},
99 minetest.register_ore({
101 ore = "default:gravel",
102 wherein = {"default:stone"},
103 clust_scarcity = 24*24*24,
107 noise_threshhold = 0,
111 spread={x=5, y=5, z=5},
118 minetest.register_ore({
119 ore_type = "scatter",
120 ore = "default:stone_with_coal",
121 wherein = "default:stone",
122 clust_scarcity = 8*8*8,
129 minetest.register_ore({
130 ore_type = "scatter",
131 ore = "default:stone_with_coal",
132 wherein = "default:stone",
133 clust_scarcity = 24*24*24,
140 minetest.register_ore({
141 ore_type = "scatter",
142 ore = "default:stone_with_iron",
143 wherein = "default:stone",
144 clust_scarcity = 12*12*12,
151 minetest.register_ore({
152 ore_type = "scatter",
153 ore = "default:stone_with_iron",
154 wherein = "default:stone",
155 clust_scarcity = 9*9*9,
162 minetest.register_ore({
163 ore_type = "scatter",
164 ore = "default:stone_with_iron",
165 wherein = "default:stone",
166 clust_scarcity = 7*7*7,
173 minetest.register_ore({
174 ore_type = "scatter",
175 ore = "default:stone_with_iron",
176 wherein = "default:stone",
177 clust_scarcity = 24*24*24,
184 minetest.register_ore({
185 ore_type = "scatter",
186 ore = "default:stone_with_mese",
187 wherein = "default:stone",
188 clust_scarcity = 18*18*18,
195 minetest.register_ore({
196 ore_type = "scatter",
197 ore = "default:stone_with_mese",
198 wherein = "default:stone",
199 clust_scarcity = 14*14*14,
206 minetest.register_ore({
207 ore_type = "scatter",
208 ore = "default:mese",
209 wherein = "default:stone",
210 clust_scarcity = 36*36*36,
217 minetest.register_ore({
218 ore_type = "scatter",
219 ore = "default:stone_with_gold",
220 wherein = "default:stone",
221 clust_scarcity = 15*15*15,
228 minetest.register_ore({
229 ore_type = "scatter",
230 ore = "default:stone_with_gold",
231 wherein = "default:stone",
232 clust_scarcity = 13*13*13,
239 minetest.register_ore({
240 ore_type = "scatter",
241 ore = "default:stone_with_diamond",
242 wherein = "default:stone",
243 clust_scarcity = 17*17*17,
250 minetest.register_ore({
251 ore_type = "scatter",
252 ore = "default:stone_with_diamond",
253 wherein = "default:stone",
254 clust_scarcity = 15*15*15,
261 minetest.register_ore({
262 ore_type = "scatter",
263 ore = "default:stone_with_copper",
264 wherein = "default:stone",
265 clust_scarcity = 12*12*12,
272 minetest.register_ore({
273 ore_type = "scatter",
274 ore = "default:stone_with_copper",
275 wherein = "default:stone",
276 clust_scarcity = 9*9*9,
290 function default.register_biomes()
291 minetest.clear_registered_biomes()
293 minetest.register_biome({
294 name = "default:grassland",
296 node_top = "default:dirt_with_grass",
298 node_filler = "default:dirt",
301 --node_water_top = "",
302 --depth_water_top = ,
310 minetest.register_biome({
311 name = "default:grassland_ocean",
313 node_top = "default:sand",
315 node_filler = "default:sand",
318 --node_water_top = "",
319 --depth_water_top = ,
330 -- Register mgv6 decorations
334 function default.register_mgv6_decorations()
338 minetest.register_decoration({
339 deco_type = "simple",
340 place_on = {"default:dirt_with_grass"},
345 spread = {x=100, y=100, z=100},
352 decoration = "default:papyrus",
355 spawn_by = "default:water_source",
360 minetest.register_decoration({
361 deco_type = "simple",
362 place_on = {"default:desert_sand"},
367 spread = {x=100, y=100, z=100},
374 decoration = "default:cactus",
382 minetest.register_decoration({
383 deco_type = "simple",
384 place_on = {"default:dirt_with_grass"},
389 spread = {x=100, y=100, z=100},
396 decoration = "default:grass_"..length,
402 minetest.register_decoration({
403 deco_type = "simple",
404 place_on = {"default:desert_sand"},
409 spread = {x=100, y=100, z=100},
416 decoration = "default:dry_shrub",
422 -- Register decorations
426 function default.register_decorations()
430 minetest.register_decoration({
431 deco_type = "simple",
432 place_on = {"default:dirt_with_grass"},
437 spread = {x=200, y=200, z=200},
442 biomes = {"default:grassland"},
445 decoration = "flowers:rose",
448 minetest.register_decoration({
449 deco_type = "simple",
450 place_on = {"default:dirt_with_grass"},
455 spread = {x=200, y=200, z=200},
460 biomes = {"default:grassland"},
463 decoration = "flowers:tulip",
466 minetest.register_decoration({
467 deco_type = "simple",
468 place_on = {"default:dirt_with_grass"},
473 spread = {x=200, y=200, z=200},
478 biomes = {"default:grassland"},
481 decoration = "flowers:dandelion_yellow",
484 minetest.register_decoration({
485 deco_type = "simple",
486 place_on = {"default:dirt_with_grass"},
491 spread = {x=200, y=200, z=200},
496 biomes = {"default:grassland"},
499 decoration = "flowers:geranium",
502 minetest.register_decoration({
503 deco_type = "simple",
504 place_on = {"default:dirt_with_grass"},
509 spread = {x=200, y=200, z=200},
514 biomes = {"default:grassland"},
517 decoration = "flowers:viola",
520 minetest.register_decoration({
521 deco_type = "simple",
522 place_on = {"default:dirt_with_grass"},
527 spread = {x=200, y=200, z=200},
532 biomes = {"default:grassland"},
535 decoration = "flowers:dandelion_white",
540 minetest.register_decoration({
541 deco_type = "simple",
542 place_on = {"default:dirt_with_grass"},
547 spread = {x=200, y=200, z=200},
552 biomes = {"default:grassland"},
555 decoration = "default:grass_1",
558 minetest.register_decoration({
559 deco_type = "simple",
560 place_on = {"default:dirt_with_grass"},
565 spread = {x=200, y=200, z=200},
570 biomes = {"default:grassland"},
573 decoration = "default:grass_2",
576 minetest.register_decoration({
577 deco_type = "simple",
578 place_on = {"default:dirt_with_grass"},
583 spread = {x=200, y=200, z=200},
588 biomes = {"default:grassland"},
591 decoration = "default:grass_3",
594 minetest.register_decoration({
595 deco_type = "simple",
596 place_on = {"default:dirt_with_grass"},
601 spread = {x=200, y=200, z=200},
606 biomes = {"default:grassland"},
609 decoration = "default:grass_4",
612 minetest.register_decoration({
613 deco_type = "simple",
614 place_on = {"default:dirt_with_grass"},
619 spread = {x=200, y=200, z=200},
624 biomes = {"default:grassland"},
627 decoration = "default:grass_5",
633 -- Detect mapgen to select functions
637 -- Mods using singlenode mapgen can call these functions to enable
638 -- the use of minetest.generate_ores or minetest.generate_decorations
640 local mg_params = minetest.get_mapgen_params()
641 if mg_params.mgname == "v5" then
642 default.register_ores()
643 default.register_biomes()
644 default.register_decorations()
645 elseif mg_params.mgname == "v6" then
646 default.register_ores()
647 default.register_mgv6_decorations()
648 elseif mg_params.mgname == "v7" then
649 default.register_ores()
650 default.register_biomes()
651 default.register_decorations()
656 -- Generate nyan cats in all mapgens
660 -- facedir: 0/1/2/3 (head node facedir value)
661 -- length: length of rainbow tail
662 function default.make_nyancat(pos, facedir, length)
663 local tailvec = {x=0, y=0, z=0}
666 elseif facedir == 1 then
668 elseif facedir == 2 then
670 elseif facedir == 3 then
673 --print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
677 local p = {x=pos.x, y=pos.y, z=pos.z}
678 minetest.set_node(p, {name="default:nyancat", param2=facedir})
680 p.x = p.x + tailvec.x
681 p.z = p.z + tailvec.z
682 minetest.set_node(p, {name="default:nyancat_rainbow", param2=facedir})
687 function default.generate_nyancats(minp, maxp, seed)
688 local height_min = -31000
689 local height_max = -32
690 if maxp.y < height_min or minp.y > height_max then
693 local y_min = math.max(minp.y, height_min)
694 local y_max = math.min(maxp.y, height_max)
695 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
696 local pr = PseudoRandom(seed + 9324342)
697 local max_num_nyancats = math.floor(volume / (16*16*16))
698 for i=1,max_num_nyancats do
699 if pr:next(0, 1000) == 0 then
700 local x0 = pr:next(minp.x, maxp.x)
701 local y0 = pr:next(minp.y, maxp.y)
702 local z0 = pr:next(minp.z, maxp.z)
703 local p0 = {x=x0, y=y0, z=z0}
704 default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
710 minetest.register_on_generated(default.generate_nyancats)
714 -- Deprecated ore generation code
718 function default.generate_ore(name, wherein, minp, maxp, seed,
719 chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
720 minetest.log('action', "WARNING: default.generate_ore is deprecated")
722 if maxp.y < height_min or minp.y > height_max then
725 local y_min = math.max(minp.y, height_min)
726 local y_max = math.min(maxp.y, height_max)
727 if chunk_size >= y_max - y_min + 1 then
730 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
731 local pr = PseudoRandom(seed)
732 local num_chunks = math.floor(chunks_per_volume * volume)
733 local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
734 --print("generate_ore num_chunks: "..dump(num_chunks))
735 for i=1,num_chunks do
736 local y0 = pr:next(y_min, y_max-chunk_size+1)
737 if y0 >= height_min and y0 <= height_max then
738 local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
739 local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
740 local p0 = {x=x0, y=y0, z=z0}
741 for x1=0,chunk_size-1 do
742 for y1=0,chunk_size-1 do
743 for z1=0,chunk_size-1 do
744 if pr:next(1,inverse_chance) == 1 then
748 local p2 = {x=x2, y=y2, z=z2}
749 if minetest.get_node(p2).name == wherein then
750 minetest.set_node(p2, {name=name})
758 --print("generate_ore done")