diff KBF.lua @ 51:7d961c698b71

fixes for vehicle swapping, and add earthliving to known enchants
author Chris Mellon <arkanes@gmail.com>
date Sun, 05 Jun 2011 13:32:47 -0500
parents 95dfc062e583
children c4324144d380
line wrap: on
line diff
--- a/KBF.lua	Sun Jun 05 13:31:43 2011 -0500
+++ b/KBF.lua	Sun Jun 05 13:32:47 2011 -0500
@@ -46,9 +46,19 @@
 function kbf:PollForVehicleChange(event, unit)
     if unit ~= "player" then return end
     self.dirty = true
-    -- hax until SAH supports vehicles - do the swap after we come out of combat
-    -- always poll instead of insta-swapping OOC in order to simplify the UnitHasVehicleUI logic
-	self.pollForUnitChange = true
+    local function performSwap()
+    	if UnitHasVehicleUI("player") then
+			-- only swap if we're in a "real" vehicle with its own actions
+        	-- There is possibly a timing issue here where
+        	-- we have set the poll flag but the unit is not 
+        	-- actually "in" the vehicle yet. I'm hoping thats 
+        	-- handled by using exited/entered events instead of exiting/entering
+            self.secureHeader:SetAttribute("unit", "vehicle")
+        else
+            self.secureHeader:SetAttribute("unit", "player")
+        end
+    end
+    self:QueueForOOC(performSwap)
 end
 
 function kbf:HideBlizzardBuffFrames()
@@ -77,24 +87,10 @@
 	end
 end
 
-function kbf:OnUpdate()
-    if self.pollForUnitChange and not InCombatLockdown() then
-        if UnitHasVehicleUI("player") then
-			-- only swap if we're in a "real" vehicle with its own actions
-        	-- There is possibly a timing issue here where
-        	-- we have set the poll flag but the unit is not 
-        	-- actually "in" the vehicle yet. I'm hoping thats 
-        	-- handled by using exited/entered events instead of exiting/entering
-            self.secureHeader:SetAttribute("unit", "vehicle")
-        else
-            self.secureHeader:SetAttribute("unit", "player")
-        end
-        self.pollForUnitChange = nil
-    end
-    
+function kbf:OnUpdate()   
     -- TODO: only start this polling when we leave combat?
     while #self.oocQueue > 0  and not InCombatLockdown() do
-		func = table.remove(self.oocQueue)
+		local func = table.remove(self.oocQueue)
 		func()
     end
     
@@ -172,10 +168,6 @@
             self:QueueForOOC(function() self.tempEnchant3:SetAttribute('target-slot', 18) end)
 			-- set up the tooltip
 		end
-		-- TODO: If we're out of combat and theres an OH enchant,
-		-- create a secure action button & position it relative 
-		-- to that. What happens when the OH weapon enchant frame
-		-- is hidden by SAH?
 		-- most likely: it stays visible but stops moving.
 		-- in this case, maybe parent it to the OH enchant also
 		-- so it vanishes and gets out of the way.
@@ -284,6 +276,7 @@
     local knownEnchants = {
     	["Flametongue"] = {8024, 30*60},
     	["Frostbrand"] = {8033, 30*60},
+    	["Earthliving"] = {51730, 30*60},
     	["Instant Poison"] = {8680, 60*60},
     	["Wound Poison"] = {13218, 60*60},
     	["Deadly Poison"] = {2823, 60*60},