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",
361 minetest.register_decoration({
362 deco_type = "simple",
363 place_on = {"default:desert_sand"},
368 spread = {x=100, y=100, z=100},
375 decoration = "default:cactus",
383 minetest.register_decoration({
384 deco_type = "simple",
385 place_on = {"default:dirt_with_grass"},
390 spread = {x=100, y=100, z=100},
397 decoration = "default:grass_"..length,
403 minetest.register_decoration({
404 deco_type = "simple",
405 place_on = {"default:desert_sand"},
410 spread = {x=100, y=100, z=100},
417 decoration = "default:dry_shrub",
423 -- Register decorations
427 function default.register_decorations()
431 minetest.register_decoration({
432 deco_type = "simple",
433 place_on = {"default:dirt_with_grass"},
438 spread = {x=200, y=200, z=200},
443 biomes = {"default:grassland"},
446 decoration = "flowers:rose",
449 minetest.register_decoration({
450 deco_type = "simple",
451 place_on = {"default:dirt_with_grass"},
456 spread = {x=200, y=200, z=200},
461 biomes = {"default:grassland"},
464 decoration = "flowers:tulip",
467 minetest.register_decoration({
468 deco_type = "simple",
469 place_on = {"default:dirt_with_grass"},
474 spread = {x=200, y=200, z=200},
479 biomes = {"default:grassland"},
482 decoration = "flowers:dandelion_yellow",
485 minetest.register_decoration({
486 deco_type = "simple",
487 place_on = {"default:dirt_with_grass"},
492 spread = {x=200, y=200, z=200},
497 biomes = {"default:grassland"},
500 decoration = "flowers:geranium",
503 minetest.register_decoration({
504 deco_type = "simple",
505 place_on = {"default:dirt_with_grass"},
510 spread = {x=200, y=200, z=200},
515 biomes = {"default:grassland"},
518 decoration = "flowers:viola",
521 minetest.register_decoration({
522 deco_type = "simple",
523 place_on = {"default:dirt_with_grass"},
528 spread = {x=200, y=200, z=200},
533 biomes = {"default:grassland"},
536 decoration = "flowers:dandelion_white",
541 minetest.register_decoration({
542 deco_type = "simple",
543 place_on = {"default:dirt_with_grass"},
548 spread = {x=200, y=200, z=200},
553 biomes = {"default:grassland"},
556 decoration = "default:grass_1",
559 minetest.register_decoration({
560 deco_type = "simple",
561 place_on = {"default:dirt_with_grass"},
566 spread = {x=200, y=200, z=200},
571 biomes = {"default:grassland"},
574 decoration = "default:grass_2",
577 minetest.register_decoration({
578 deco_type = "simple",
579 place_on = {"default:dirt_with_grass"},
584 spread = {x=200, y=200, z=200},
589 biomes = {"default:grassland"},
592 decoration = "default:grass_3",
595 minetest.register_decoration({
596 deco_type = "simple",
597 place_on = {"default:dirt_with_grass"},
602 spread = {x=200, y=200, z=200},
607 biomes = {"default:grassland"},
610 decoration = "default:grass_4",
613 minetest.register_decoration({
614 deco_type = "simple",
615 place_on = {"default:dirt_with_grass"},
620 spread = {x=200, y=200, z=200},
625 biomes = {"default:grassland"},
628 decoration = "default:grass_5",
634 -- Detect mapgen to select functions
638 -- Mods using singlenode mapgen can call these functions to enable
639 -- the use of minetest.generate_ores or minetest.generate_decorations
641 local mg_params = minetest.get_mapgen_params()
642 if mg_params.mgname == "v5" then
643 default.register_ores()
644 default.register_biomes()
645 default.register_decorations()
646 elseif mg_params.mgname == "v6" then
647 default.register_ores()
648 default.register_mgv6_decorations()
649 elseif mg_params.mgname == "v7" then
650 default.register_ores()
651 default.register_biomes()
652 default.register_decorations()
657 -- Generate nyan cats in all mapgens
661 -- facedir: 0/1/2/3 (head node facedir value)
662 -- length: length of rainbow tail
663 function default.make_nyancat(pos, facedir, length)
664 local tailvec = {x=0, y=0, z=0}
667 elseif facedir == 1 then
669 elseif facedir == 2 then
671 elseif facedir == 3 then
674 --print("default.make_nyancat(): Invalid facedir: "+dump(facedir))
678 local p = {x=pos.x, y=pos.y, z=pos.z}
679 minetest.set_node(p, {name="default:nyancat", param2=facedir})
681 p.x = p.x + tailvec.x
682 p.z = p.z + tailvec.z
683 minetest.set_node(p, {name="default:nyancat_rainbow", param2=facedir})
688 function default.generate_nyancats(minp, maxp, seed)
689 local height_min = -31000
690 local height_max = -32
691 if maxp.y < height_min or minp.y > height_max then
694 local y_min = math.max(minp.y, height_min)
695 local y_max = math.min(maxp.y, height_max)
696 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
697 local pr = PseudoRandom(seed + 9324342)
698 local max_num_nyancats = math.floor(volume / (16*16*16))
699 for i=1,max_num_nyancats do
700 if pr:next(0, 1000) == 0 then
701 local x0 = pr:next(minp.x, maxp.x)
702 local y0 = pr:next(minp.y, maxp.y)
703 local z0 = pr:next(minp.z, maxp.z)
704 local p0 = {x=x0, y=y0, z=z0}
705 default.make_nyancat(p0, pr:next(0,3), pr:next(3,15))
711 minetest.register_on_generated(default.generate_nyancats)
715 -- Deprecated ore generation code
719 function default.generate_ore(name, wherein, minp, maxp, seed,
720 chunks_per_volume, chunk_size, ore_per_chunk, height_min, height_max)
721 minetest.log('action', "WARNING: default.generate_ore is deprecated")
723 if maxp.y < height_min or minp.y > height_max then
726 local y_min = math.max(minp.y, height_min)
727 local y_max = math.min(maxp.y, height_max)
728 if chunk_size >= y_max - y_min + 1 then
731 local volume = (maxp.x-minp.x+1)*(y_max-y_min+1)*(maxp.z-minp.z+1)
732 local pr = PseudoRandom(seed)
733 local num_chunks = math.floor(chunks_per_volume * volume)
734 local inverse_chance = math.floor(chunk_size*chunk_size*chunk_size / ore_per_chunk)
735 --print("generate_ore num_chunks: "..dump(num_chunks))
736 for i=1,num_chunks do
737 local y0 = pr:next(y_min, y_max-chunk_size+1)
738 if y0 >= height_min and y0 <= height_max then
739 local x0 = pr:next(minp.x, maxp.x-chunk_size+1)
740 local z0 = pr:next(minp.z, maxp.z-chunk_size+1)
741 local p0 = {x=x0, y=y0, z=z0}
742 for x1=0,chunk_size-1 do
743 for y1=0,chunk_size-1 do
744 for z1=0,chunk_size-1 do
745 if pr:next(1,inverse_chance) == 1 then
749 local p2 = {x=x2, y=y2, z=z2}
750 if minetest.get_node(p2).name == wherein then
751 minetest.set_node(p2, {name=name})
759 --print("generate_ore done")