2.4.3 addon, tells you how far you are from nearest graveyards
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
988B

  1. -- spirits module
  2. spirits = {}
  3. -- finds all spirit healers by given zone
  4. function spirits.find(zone)
  5. for i, v in pairs(locations) do
  6. if i % 2 ~= 0 then
  7. if v == zone then
  8. return locations[i+1]
  9. end
  10. end
  11. end
  12. return nil
  13. end
  14. -- determine given player's distance to spirit healers in resolved zone
  15. function spirits.distances(player)
  16. local zone = player.zone()
  17. local locs = spirits.find(zone)
  18. if nil == locs then
  19. return string.format("No spirits found for zone: %s", zone)
  20. end
  21. local msg = ""
  22. for j, coords in pairs(locs) do
  23. x, y = unpack(coords)
  24. dx = math.abs(player.x() - x)
  25. dy = math.abs(player.y() - y)
  26. dist = math.max(dx, dy)
  27. color = "cffFF0000"
  28. if dist < 3 then
  29. color = "cff00FF00"
  30. elseif dist < 10 then
  31. color = "cffFFFF00"
  32. else
  33. color = "cffFF0000"
  34. end
  35. msg = msg .. string.format("|%s%.2f|r away from %d", color, dist, j) .. ";"
  36. end
  37. return msg
  38. end