|
-
- -- spirits module
- spirits = {}
-
- -- finds all spirit healers by given zone
- function spirits.find(zone)
- for i, v in pairs(locations) do
- if i % 2 ~= 0 then
- if v == zone then
- return locations[i+1]
- end
- end
- end
-
- return nil
- end
-
- -- determine given player's distance to spirit healers in resolved zone
- function spirits.distances(player)
-
- local zone = player.zone()
- local locs = spirits.find(zone)
-
- if nil == locs then
- return string.format("No spirits found for zone: %s", zone)
- end
-
- local msg = ""
- for j, coords in pairs(locs) do
- x, y = unpack(coords)
- dx = math.abs(player.x() - x)
- dy = math.abs(player.y() - y)
-
- dist = math.max(dx, dy)
- color = "cffFF0000"
-
- if dist < 3 then
- color = "cff00FF00"
- elseif dist < 10 then
- color = "cffFFFF00"
- else
- color = "cffFF0000"
- end
-
- msg = msg .. string.format("|%s%.2f|r away from %d", color, dist, j) .. ";"
- end
-
- return msg
- end
|