Advertisement
Guest User

RuneHUD

a guest
Sep 6th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.65 KB | None | 0 0
  1. --CONFIG--------------------------------------------
  2. local x1 = 103      y1 = 23             -- Coordinate for the first blood and the second unholy rune
  3. local x2 = 72       y2 = 61             -- Coordinate for the second blood and the first unholy rune
  4. local x3 = 25       y3 = 80             -- Coordinate for the first and second frost runes
  5. ---------------------------------------------------------
  6.  
  7. SLASH_RUNEHUD1, SLASH_RUNEHUD2 = '/runehud', '/rh';
  8. local function handler(msg, editbox)
  9. local command, rest = msg:match("^(%S*)%s*(.-)$")
  10.     if command == 's' then
  11.         if tonumber(rest) ~= nil then
  12.             if tonumber(rest) > 0 then
  13.                 RHs = tonumber(rest)
  14.                 RuneFrame:SetScale(RHs)
  15.                 RuneButtonIndividual1:ClearAllPoints()
  16.                 RuneButtonIndividual1:SetPoint("CENTER", UIParent, "CENTER", -x1, y1)
  17.             else
  18.                 print("RuneHUD: You need to use a valid value for the scale");
  19.             end
  20.         else
  21.             print("RuneHUD: You need to use a valid value for the scale");
  22.         end
  23.     elseif command == 'aoc' then
  24.         if tonumber(rest) ~= nil then
  25.             if tonumber(rest) >= 0 then
  26.                 RHaoc = tonumber(rest)
  27.                 if InCombatLockdown() == nil then
  28.                     RuneFrame:SetAlpha(RHaoc)
  29.                 end
  30.             else
  31.                 print("RuneHUD: You need to use a valid value for the alpha");
  32.             end
  33.         else
  34.             print("RuneHUD: You need to use a valid value for the alpha");
  35.         end
  36.     elseif command == 'aic' then
  37.         if tonumber(rest) ~= nil then
  38.             if tonumber(rest) >= 0 then
  39.                 RHaic = tonumber(rest)
  40.                 if InCombatLockdown() then
  41.                     RuneFrame:SetAlpha(RHaic)
  42.                 end
  43.             else
  44.                 print("RuneHUD: You need to use a valid value for the alpha");
  45.             end
  46.         else
  47.             print("RuneHUD: You need to use a valid value for the alpha");
  48.         end
  49.     elseif command == 'aiv' then
  50.         if tonumber(rest) ~= nil then
  51.             if tonumber(rest) >= 0 then
  52.                 RHaiv = tonumber(rest)
  53.                 if UnitInVehicle("player") then
  54.                     RuneFrame:SetAlpha(RHaiv)
  55.                 end
  56.             else
  57.                 print("RuneHUD: You need to use a valid value for the alpha");
  58.             end
  59.         else
  60.             print("RuneHUD: You need to use a valid value for the alpha");
  61.         end
  62.     elseif command == 'hoc' and tostring(rest) == "false" or tostring(rest) == "true" then
  63.         RHhoc = tostring(rest)
  64.     elseif command == 'hoc' then
  65.         print("RuneHUD: The cooldown fading options has been disabled due to weird bugs with it");
  66.     else
  67.         print("RuneHUD: The available slash commands are:");
  68.         print("RuneHUD: '/rh s <scale>' for scaling");
  69.         print("RuneHUD: '/rh aoc <alpha>' for out of combat alpha");
  70.         print("RuneHUD: '/rh aic <alpha>' for alpha in combat");
  71.         print("RuneHUD: '/rh aiv <alpha>' for alpha when in a vehicle");
  72.     end
  73. end
  74. SlashCmdList["RUNEHUD"] = handler;
  75.  
  76.  
  77. --Clearing the old position
  78. RuneButtonIndividual1:ClearAllPoints()
  79. RuneButtonIndividual2:ClearAllPoints()
  80. RuneButtonIndividual3:ClearAllPoints()
  81. RuneButtonIndividual4:ClearAllPoints()
  82. RuneButtonIndividual5:ClearAllPoints()
  83. RuneButtonIndividual6:ClearAllPoints()
  84.  
  85. --Setting the new position, change the x,y  values in the end of each line to move the runes
  86. RuneButtonIndividual1:SetPoint("CENTER", UIParent, "CENTER", -x1, y1)
  87. RuneButtonIndividual2:SetPoint("CENTER", UIParent, "CENTER", -x2, y2)
  88. RuneButtonIndividual5:SetPoint("CENTER", UIParent, "CENTER", -x3, y3)
  89. RuneButtonIndividual6:SetPoint("CENTER", UIParent, "CENTER", x3, y3)
  90. RuneButtonIndividual3:SetPoint("CENTER", UIParent, "CENTER", x2, y2)
  91. RuneButtonIndividual4:SetPoint("CENTER", UIParent, "CENTER", x1, y1)
  92.  
  93. --Making the runes click through
  94. RuneButtonIndividual1:EnableMouse(false)
  95. RuneButtonIndividual2:EnableMouse(false)
  96. RuneButtonIndividual3:EnableMouse(false)
  97. RuneButtonIndividual4:EnableMouse(false)
  98. RuneButtonIndividual5:EnableMouse(false)
  99. RuneButtonIndividual6:EnableMouse(false)
  100.  
  101. local function Runehud_OnEvent(self, event, ...)
  102. local arg1 = ...
  103.  
  104.     if event == "PLAYER_ENTERING_WORLD" then
  105.         RuneButtonIndividual1:ClearAllPoints()
  106.         RuneButtonIndividual1:SetPoint("CENTER", UIParent, "CENTER", -x1, y1)
  107.        
  108.         if RHs == nil then
  109.             RHs = 1.2
  110.         end
  111.         if RHaoc == nil then
  112.             RHaoc = 0.1
  113.         end
  114.         if RHaic == nil then
  115.             RHaic = 1
  116.         end
  117.         if RHaiv == nil then
  118.             RHaiv = 0
  119.         end
  120.         if RHhoc == nil then
  121.             RHhoc = "false"
  122.         end
  123.     end
  124.    
  125.     if (event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_REGEN_ENABLED") and not UnitInVehicleControlSeat("player") then
  126.         RuneFrame:SetAlpha(RHaoc)  
  127.         RuneFrame:SetScale(RHs)    
  128.     elseif event == "PLAYER_REGEN_DISABLED" and not UnitInVehicleControlSeat("player") then
  129.         RuneFrame:SetAlpha(RHaic)
  130.         RuneFrame:SetScale(RHs)
  131.     end
  132.    
  133.     if ((event == "UNIT_ENTERING_VEHICLE") and UnitInVehicleControlSeat("player"))  then
  134.         local unitID = ...
  135.         if unitID == "player" then
  136.             RuneFrame:SetAlpha(RHaiv)  
  137.         end
  138.     elseif event == "PLAYER_ENTERING_WORLD" then
  139.         if InCombatLockdown() then
  140.             RuneFrame:SetAlpha(RHaic)
  141.             RuneFrame:SetScale(RHs)
  142.         else
  143.             RuneFrame:SetAlpha(RHaoc)
  144.             RuneFrame:SetScale(RHs)
  145.         end
  146.     elseif event == "UNIT_EXITED_VEHICLE" then
  147.         local unitID = ...
  148.         if unitID == "player" then
  149.             if InCombatLockdown() then
  150.                 RuneFrame:SetAlpha(RHaic)
  151.                 RuneFrame:SetScale(RHs)
  152.             else
  153.                 RuneFrame:SetAlpha(RHaoc)
  154.                 RuneFrame:SetScale(RHs)
  155.             end
  156.         end
  157.     end
  158.    
  159.     if RHhoc == "true" then
  160.         if event == "PLAYER_REGEN_DISABLED" then
  161.             if GetRuneCooldown(1) > 0 then
  162.                 RuneButtonIndividual1:SetAlpha(RHaoc) else
  163.                 RuneButtonIndividual1:SetAlpha(RHaic)
  164.             end
  165.             if GetRuneCooldown(2) > 0 then
  166.                 RuneButtonIndividual2:SetAlpha(RHaoc) else
  167.                 RuneButtonIndividual2:SetAlpha(RHaic)
  168.             end
  169.             if GetRuneCooldown(3) > 0 then
  170.                 RuneButtonIndividual3:SetAlpha(RHaoc) else
  171.                 RuneButtonIndividual3:SetAlpha(RHaic)
  172.             end
  173.             if GetRuneCooldown(4) > 0 then
  174.                 RuneButtonIndividual4:SetAlpha(RHaoc) else
  175.                 RuneButtonIndividual4:SetAlpha(RHaic)
  176.             end
  177.             if GetRuneCooldown(5) > 0 then
  178.                 RuneButtonIndividual5:SetAlpha(RHaoc) else
  179.                 RuneButtonIndividual5:SetAlpha(RHaic)
  180.             end
  181.             if GetRuneCooldown(6) > 0 then
  182.                 RuneButtonIndividual6:SetAlpha(RHaoc) else
  183.                 RuneButtonIndividual6:SetAlpha(RHaic)
  184.             end
  185.            
  186.         elseif event == "RUNE_POWER_UPDATE" and InCombatLockdown() and not UnitInVehicleControlSeat("player") then
  187.             local runeIndex, isEnergize = ...;
  188.             local runeButton = _G["RuneButtonIndividual"..runeIndex];
  189.             local start, duration, runeReady = GetRuneCooldown(runeIndex);
  190.             print(GetTime(),runeIndex,start,duration,runeReady,isEnergize)
  191.             if not runeReady and isEnergize == nil then
  192.                
  193.                     runeButton:SetAlpha(RHaoc)
  194.                
  195.             else
  196.                 runeButton:SetAlpha(RHaic)
  197.             end
  198.        
  199.             if isEnergize then
  200.                 runeButton:SetAlpha(RHaic)
  201.             end
  202.                
  203.         elseif (event == "PLAYER_REGEN_ENABLED" and not UnitInVehicleControlSeat("player")) then
  204.             RuneButtonIndividual1:SetAlpha(RHaic)
  205.             RuneButtonIndividual2:SetAlpha(RHaic)
  206.             RuneButtonIndividual3:SetAlpha(RHaic)
  207.             RuneButtonIndividual4:SetAlpha(RHaic)
  208.             RuneButtonIndividual5:SetAlpha(RHaic)
  209.             RuneButtonIndividual6:SetAlpha(RHaic)
  210.         elseif event == "UNIT_EXITED_VEHICLE" then
  211.             local unitID = ...
  212.             if unitID == "player" then
  213.                 RuneButtonIndividual1:SetAlpha(RHaic)
  214.                 RuneButtonIndividual2:SetAlpha(RHaic)
  215.                 RuneButtonIndividual3:SetAlpha(RHaic)
  216.                 RuneButtonIndividual4:SetAlpha(RHaic)
  217.                 RuneButtonIndividual5:SetAlpha(RHaic)
  218.                 RuneButtonIndividual6:SetAlpha(RHaic)
  219.             end
  220.         end
  221.     end
  222. end
  223.  
  224.  
  225. local f = CreateFrame("Frame","RuneHUDFrame",UIParent)
  226. f:RegisterEvent("PLAYER_REGEN_DISABLED")
  227. f:RegisterEvent("PLAYER_REGEN_ENABLED")
  228. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  229. f:RegisterEvent("UNIT_EXITED_VEHICLE")
  230. f:RegisterEvent("UNIT_ENTERING_VEHICLE")
  231. f:RegisterEvent("RUNE_POWER_UPDATE")
  232. f:RegisterEvent("RUNE_TYPE_UPDATE");
  233. f:RegisterEvent("RUNE_REGEN_UPDATE");
  234. f:SetScript("OnEvent", Runehud_OnEvent)
  235. RuneFrame:SetParent(RuneHUDFrame)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement