Advertisement
Guest User

Tol Barad Timer

a guest
Jun 19th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.72 KB | None | 0 0
  1. local function StartMoving(self,button)
  2.   if ( button ~= "LeftButton" ) then return end
  3.   if ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) then
  4.     if ( self:IsMovable() ) then
  5.       self:StartMoving();
  6.       self.isMoving = true;
  7.       self.hasMoved = false;
  8.     end
  9.   end
  10. end
  11.  
  12. local function StopMoving(self,button)
  13.   if ( button ~= "LeftButton" ) then return end
  14.   if ( self.isMoving ) then
  15.     self:StopMovingOrSizing();
  16.     self.isMoving = false;
  17.     self.hasMoved = true;
  18.   end
  19. end
  20.  
  21. local function On_Update()
  22.     a,b,c,d,WaitTime,e = GetWorldPVPAreaInfo(2)
  23.     WaitStringFormat()
  24.     Time:SetText(WaitTimeMes)
  25. end
  26.  
  27.  function WaitStringFormat()
  28.    
  29.     if WaitTime >= 3600 then
  30.         WaitTimeMes = string.format("%d:%02d:%02d", math.floor(WaitTime/3600),math.floor((WaitTime%3600)/60), math.floor(((WaitTime%3600)%60)))
  31.     end
  32.    
  33.     if WaitTime < 3600 then
  34.         if WaitTime >= 60 then
  35.             WaitTimeMes = string.format("%02d:%02d", math.floor(WaitTime/60), math.floor(WaitTime%60))
  36.         end
  37.     end
  38.    
  39.     if WaitTime < 60 then
  40.         WaitTimeMes = WaitTime
  41.     end
  42.    
  43. end
  44.                    
  45. local TBFrame = CreateFrame ("FRAME", "TBFrame", UIParent, nil)
  46.  TBFrame:RegisterEvent("ADDON_LOADED")
  47.  TBFrame:RegisterEvent("VARIABLES_LOADED")
  48.  TBFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
  49.  TBFrame:RegisterEvent("PLAYER_LOGIN")
  50.  TBFrame:SetWidth(130)
  51.  TBFrame:SetHeight(30)
  52.  TBFrame:SetPoint("CENTER", UIParent, "CENTER")
  53.  TBFrame:SetBackdrop({bgFile = [[Interface\DialogFrame\UI-DialogBox-Background]],})
  54.  TBFrame:Show(true)
  55.  TBFrame:SetMovable(true)
  56.  TBFrame:EnableMouse(true)
  57.  TBFrame:SetScale(1.0, 1.0)
  58.  TBFrame:SetAlpha(1)
  59.  
  60.  local Time = TBFrame:CreateFontString("Time", "OVERLAY", FontInstance)
  61.  Time:SetPoint("RIGHT", TBFrame, "RIGHT", -5, 0)
  62.  Time:SetFont("Fonts\\FRIZQT__.TTF", 20, nil)
  63.  
  64.  local TBTexture = TBFrame:CreateTexture("Faction Icon", "OVERLAY", nil)
  65.   TBTexture:SetPoint("TOPLEFT", TBFrame, "TOPLEFT")
  66.  
  67.  local Ally = "Interface\\PVPFrame\\PVP-Currency-Alliance"
  68.  local Horde = "Interface\\PVPFrame\\PVP-Currency-Horde"
  69.  
  70.  TBFrame:SetScript("OnMouseDown", StartMoving)
  71.  TBFrame:SetScript("OnMouseUp", StopMoving)
  72.  TBFrame:SetScript("OnEvent", function()
  73.  
  74.                     SetMapByID(708)
  75.                     name, description, textureIndex, x, y = GetMapLandmarkInfo(1)
  76.                    
  77.                     if textureIndex == 46 then
  78.                         red = 0
  79.                         blue = 1
  80.                         green = 0
  81.                         Time:SetTextColor(red, green, blue)
  82.                         TBTexture:SetTexture(Ally)
  83.                     end
  84.                    
  85.                     if textureIndex == 48 then
  86.                         red = 1.0
  87.                         blue = 0
  88.                         green = 0
  89.                         Time:SetTextColor(red, green, blue)
  90.                         TBTexture:SetTexture(Horde)
  91.                     end
  92.                     _,_,_,_,WaitTime,_ = GetWorldPVPAreaInfo(2)
  93.                     TBTexture:SetTexture(Faction)
  94.                     end)
  95.  TBFrame:SetScript("OnUpdate", On_Update)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement