Shestak UI
Go Back   Shestak UI > Interface Forums > English Community > Modified Versions

Modified Versions Your modified version of ShestakUI.

Advertising

 
Thread Tools
Old 31.10.2012, 18:40   #1
 Assistant User Information

m2jest1c's Avatar
Post RangeDisplay (not same named addon)

Simple count of target range (<5, 5-8, 8-10, 10-15, 15-20, 20-25, 25-30, 30-35, 35-40, >40).


Add to the end of file ShestakUI\Modules\Misc\Misc.lua:
lua Code [Select]:
----------------------------------------------------------------------------------------
--  RangeDisplay
----------------------------------------------------------------------------------------
local RangeDisplay = UIParent:CreateFontString(nil, "OVERLAY")
RangeDisplay:SetFont(C.media.pixel_font, C.media.pixel_font_size * 2, C.media.pixel_font_style)
RangeDisplay:SetPoint("CENTER", 0, -100)
local Items = {
["Friend"] = {
        37727-- 5
        34368-- 8
        32321-- 10
        1251,   -- 15
        21519-- 20
        31463-- 25
        1180,   -- 30
        18904-- 35
        34471-- 40
    },
    ["Enemy"] = {
        37727-- 5
        34368-- 8
        32321-- 10
        33069-- 15
        10645-- 20
        31463-- 25
        835,    -- 30
        18904-- 35
        28767-- 40
    },
}
local Colors = {
    {0.3, 0.3, 0.9},    -- 0-5
    {0.3, 0.9, 0.9},    -- 5-8
    {0.3, 0.9, 0.9},    -- 5-10
    {0.3, 0.9, 0.9},    -- 10-15
    {0.9, 0.9, 0.1},    -- 15-20
    {0.9, 0.9, 0.1},    -- 20-25
    {0.1, 0.9, 0.1},    -- 25-30
    {0.9, 0.9, 0.1},    -- 30-35
    {0.9, 0.9, 0.1},    -- 35-40
    {0.9, 0.1, 0.1},    -- >40
}

local timer = 0
local f = CreateFrame("Frame")
f:SetScript("OnUpdate", function(self, elapsed)
    timer = timer + elapsed
    if timer >= 0.2 then
        local distance = 0
        local target = nil
       
        if UnitCanAssist("player", "target") and UnitIsUnit("target", "player") == nil then
            target = Items.Friend
        elseif UnitCanAttack("player", "target") then
            target = Items.Enemy
        end
       
        if target ~= nil then
            RangeDisplay:Show()
            for key, item in pairs(target) do
                if IsItemInRange(item, "target") == 0 then
                    distance = key
                end
            end
            for key, color in pairs(Colors) do
                local r, g, b = unpack(color)
                if distance == key - 1 then
                    RangeDisplay:SetTextColor(r, g, b)
                end
            end
        else
            RangeDisplay:Hide()
        end
       
        if distance == 0 then
            RangeDisplay:SetText("< 5")
        elseif distance == 1 then
            RangeDisplay:SetText("5-8")
        elseif distance == 2 then
            RangeDisplay:SetText("8-10")
        elseif distance < 9 then
            local minDistance = distance * 5 - 5
            local maxDistance = distance * 5
            RangeDisplay:SetText(minDistance.."-"..maxDistance)
        else
            RangeDisplay:SetText("> 40")
        end
       
        timer = 0
    end
end)
Says Thank:
Oz (27.10.2012), Puree (28.10.2012), Shestak (27.10.2012)
Old 31.10.2012, 18:40   #1.5 - Disable Ads

Advertise on this site

Old 31.10.2012, 18:41   #2
m2jest1c
 Assistant User Information

m2jest1c's Avatar
Updated, thaks to Oz for testing
Say Thank:
Oz (31.10.2012)

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
[4.0] RangeDisplay (не путать с аддоном) m2jest1c Modified Versions 12 20.12.2013 11:41
Different bag addon Sprites Technical Support 3 12.01.2012 04:27
Cooldown addon? Lisil General Discussion 2 29.04.2011 15:14
GTFO addon beaver General Discussion 1 04.12.2010 22:50
Questions about addon groups zzsh Technical Support 0 30.11.2010 23:34


Mobile Style Русский English Deutsch Italian Chinese