2023-02-12 21:06:08 +01:00
|
|
|
if not minetest.get_modpath("df_lorebooks") then return end
|
|
|
|
|
2023-02-12 23:45:26 +01:00
|
|
|
local foundations = {"group:stone", "group:dirt", "group:soil", "group:sand"}
|
2023-02-12 21:06:08 +01:00
|
|
|
|
|
|
|
minetest.register_on_generated(function(minp, maxp, blockseed)
|
|
|
|
if maxp.y > 0 or maxp.y < df_caverns.config.primordial_min then return end
|
|
|
|
|
|
|
|
-- using after so that all other mapgen should be finished fiddling with stuff by the time this runs
|
2023-09-30 00:09:25 +02:00
|
|
|
minetest.after(1, function(minp_after, maxp_after)
|
|
|
|
local middle = vector.divide(vector.add(minp_after, maxp_after), 2)
|
2023-02-12 21:06:08 +01:00
|
|
|
if collectible_lore.are_cairns_close_to_pos(middle) then return end -- quick and dirty check to discard mapblocks close to other cairns
|
2023-09-30 00:09:25 +02:00
|
|
|
local possibles = minetest.find_nodes_in_area_under_air(minp_after, maxp_after, foundations)
|
2023-02-12 21:06:08 +01:00
|
|
|
if next(possibles) then
|
|
|
|
local target = possibles[math.random(#possibles)]
|
|
|
|
target.y=target.y+1
|
|
|
|
collectible_lore.place_cairn(target)
|
2023-09-30 00:09:25 +02:00
|
|
|
end
|
2023-02-12 21:06:08 +01:00
|
|
|
end, minp, maxp)
|
|
|
|
|
|
|
|
end)
|