View Single Post
08-23-16, 07:30 AM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Thanks for all the Help but for now I'm just going to use:
Lua Code:
  1. CastSpellByName("Traveler's Tundra Mammoth")
beings this is the only repair mount I currently have. Eventually I will probably add the Yak as well and when that time comes maybe there will be an easier way.

For right now here is my Duarability.lua file that goes with my cData addon,
Lua Code:
  1. local cData = LibStub("AceAddon-3.0"):GetAddon("cData")
  2.  
  3. ------------------------------------------------------------------------
  4. --   Durability Plugin Functions
  5. ------------------------------------------------------------------------
  6. cData.pluginConstructors["dur"] = function()
  7.  
  8.     db = cData.db.profile
  9.    
  10.     Slots = {
  11.         [1] = {1, "Head", 1000},
  12.         [2] = {3, "Shoulder", 1000},
  13.         [3] = {5, "Chest", 1000},
  14.         [4] = {6, "Waist", 1000},
  15.         [5] = {9, "Wrist", 1000},
  16.         [6] = {10, "Hands", 1000},
  17.         [7] = {7, "Legs", 1000},
  18.         [8] = {8, "Feet", 1000},
  19.         [9] = {16, "Main Hand", 1000},
  20.         [10] = {17, "Off Hand", 1000},
  21.         [11] = {18, "Ranged", 1000}
  22.     }
  23.  
  24.  
  25.     local plugin = CreateFrame('Frame', nil, Datapanel)
  26.     plugin:EnableMouse(true)
  27.     plugin:SetFrameStrata("MEDIUM")
  28.     plugin:SetFrameLevel(3)
  29.  
  30.     local Text  = plugin:CreateFontString(nil, "OVERLAY")
  31.     Text:SetFont(db.font, db.fontSize,'THINOUTLINE')
  32.     cData:PlacePlugin(db.dur, Text)
  33.  
  34.     local function OnEvent(self)
  35.         local Total = 0
  36.         local current, max
  37.        
  38.         for i = 1, 11 do
  39.             if GetInventoryItemLink("player", Slots[i][1]) ~= nil then
  40.                 current, max = GetInventoryItemDurability(Slots[i][1])
  41.                 if current then
  42.                     Slots[i][3] = current/max
  43.                     Total = Total + 1
  44.                 end
  45.             end
  46.         end
  47.         table.sort(Slots, function(a, b) return a[3] < b[3] end)
  48.        
  49.         if Total > 0 then
  50.             Text:SetText(hexa.."Armor: "..hexb..floor(Slots[1][3]*100).."% |r")
  51.         else
  52.             Text:SetText(hexa.."Armor: "..hexb.."100% |r")
  53.         end
  54.         -- Setup Durability Tooltip
  55.         self:SetAllPoints(Text)
  56.         Total = 0
  57.     end
  58.  
  59.     plugin:RegisterEvent("UPDATE_INVENTORY_DURABILITY")
  60.     plugin:RegisterEvent("MERCHANT_SHOW")
  61.     plugin:RegisterEvent("PLAYER_ENTERING_WORLD")
  62.     plugin:SetScript("OnMouseDown",function(self,btn)
  63.         if btn == "LeftButton" then
  64.             ToggleCharacter("PaperDollFrame")
  65.         elseif btn == "RightButton" then
  66.             CastSpellByName("Traveler's Tundra Mammoth")
  67.         end
  68.     end)
  69.     plugin:SetScript("OnEvent", OnEvent)
  70.     plugin:SetScript("OnEnter", function(self)
  71.         if not InCombatLockdown() then
  72.             local anchor, panel, xoff, yoff = cData:DataTextTooltipAnchor(Text)
  73.             GameTooltip:SetOwner(panel, anchor, xoff, yoff)
  74.             GameTooltip:ClearLines()
  75.             GameTooltip:AddLine(hexa..PLAYER_NAME.."'s"..hexb.." Durability")
  76.             GameTooltip:AddLine' '         
  77.             for i = 1, 11 do
  78.                 if Slots[i][3] ~= 1000 then
  79.                     local green, red
  80.                     green = Slots[i][3]*2
  81.                     red = 1 - green
  82.                     GameTooltip:AddDoubleLine(Slots[i][2], floor(Slots[i][3]*100).."%",1 ,1 , 1, red + 1, green, 0)
  83.                 end
  84.             end
  85.         GameTooltip:AddLine(" ")
  86.         GameTooltip:AddLine("|cffeda55fLeft Click|r opens Character Panel.")
  87.         GameTooltip:AddLine("|cffeda55fRight Click|r summon's Traveler's Tundra Mammoth.")
  88.         GameTooltip:Show()
  89.         end
  90.     end)
  91.     plugin:SetScript("OnLeave", function() GameTooltip:Hide() end)
  92.  
  93.     return plugin -- important!
  94. end
Which will show up like the image below.


Thanks again Phanx for all the help you have given and still give to us not so good lua coders that want to make things our way.

Coke

Last edited by cokedrivers : 08-24-16 at 06:39 AM.
  Reply With Quote