oerkki.lua 649 B

123456789101112131415161718192021222324252627
  1. function dungeon_loot.place_oerkki_stones(data)
  2. if not data or #data < 1 then
  3. return
  4. end
  5. -- 1/3 chance to spawn.
  6. if math.random(1, 3) <= 2 then
  7. return
  8. end
  9. -- Place a random number of stones.
  10. local count = math.random(1, 3)
  11. for k = 1, count do
  12. local pos = data[math.random(1, #data)]
  13. local minp = vector.offset(pos, -5, -5, -5)
  14. local maxp = vector.offset(pos, 5, 5, 5)
  15. local targets = minetest.find_nodes_in_area_under_air(minp, maxp, dungeon_loot.DUNGEON_NODES)
  16. if targets and #targets > 0 then
  17. local target = targets[math.random(1, #targets)]
  18. minetest.set_node(target, {name="griefer:grieferstone"})
  19. end
  20. end
  21. end