123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- local find_surface = function(xz, b, t)
- for j=t, b, -1 do
- local pos = {x=xz.x, y=j, z=xz.z}
- local n = minetest.get_node(pos).name
- if snow.is_snow(n) then
- local pb = {x=pos.x, y=pos.y-1, z=pos.z}
- local nb = minetest.get_node(pb).name
- if nb == "default:stone" then
- return pos, pb -- Position, position below.
- else
- break
- end
- elseif n == "default:stone" then
- break
- end
- end
- end
- local flowers_list = {
- 'flowers:rose',
- 'flowers:rose_white',
- 'flowers:zinnia_red',
- 'flowers:tulip',
- 'flowers:dandelion_yellow',
- 'flowers:chrysanthemum_green',
- 'flowers:geranium',
- 'flowers:viola',
- 'flowers:foxglove_pink',
- "flowers:bluebell",
- "flowers:snapdragon",
- "flowers:forgetmenot",
- "flowers:daylily",
- "flowers:poppy_orange",
- "flowers:iris_black",
- "flowers:jack",
- "flowers:lupine_purple",
- 'flowers:dandelion_white',
- 'flowers:tulip_black',
- "flowers:delphinium",
- "flowers:lockspur",
- "flowers:thistle",
- "flowers:lazarus",
- "flowers:mannagrass",
- }
- local chose_flower = function(pr, pos)
- if flowers and flowers.datas then -- Only if flowers mod exists.
- local which = pr:next(1, #flowers_list)
- local name = flowers_list[which]
- minetest.set_node(pos, {name=name})
- end
- end
- mapgen.generate_flowers = function(minp, maxp, seed)
- -- Don't generate underground, don't generate in highlands.
- if maxp.y < -50 or minp.y > 300 then
- return
- end
- local pr = PseudoRandom(seed + 1892)
- local count = pr:next(1, 3)
- -- 1 in 3 chance per mapchunk.
- if count == 1 then
- local xz = {x=pr:next(minp.x, maxp.x), z=pr:next(minp.z, maxp.z)}
- local pos, posb = find_surface(xz, minp.y, maxp.y)
- -- Highlands only.
- if pos then
- if pos.y < 40 then return end
- chose_flower(pr, pos)
- -- Natural-grown flowers always appear on mossy cobble.
- minetest.set_node(posb, {name="default:mossycobble"})
- end
- end
- end
|