|
709 | 709 |
|
710 | 710 |
|
711 | 711 | minetest.register_on_generated(default.generate_nyancats)
|
712 |
| - |
713 |
| - |
714 |
| --- |
715 |
| --- Deprecated ore generation code |
716 |
| --- |
717 |
| - |
718 |
| - |
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") |
722 |
| - |
723 |
| - if maxp.y < height_min or minp.y > height_max then |
724 |
| - return |
725 |
| - end |
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 |
729 |
| - return |
730 |
| - end |
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 |
746 |
| - local x2 = x0+x1 |
747 |
| - local y2 = y0+y1 |
748 |
| - local z2 = z0+z1 |
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}) |
752 |
| - end |
753 |
| - end |
754 |
| - end |
755 |
| - end |
756 |
| - end |
757 |
| - end |
758 |
| - end |
759 |
| - --print("generate_ore done") |
760 |
| -end |
761 |
| - |
0 commit comments