Quantcast

-Changes done by Dridzt from WOWInterface. Many thanks :)

Xruptor [12-26-11 - 13:44]
-Changes done by Dridzt from WOWInterface.  Many thanks :)
-Code added to prevent actionbar issues while loading or reloading in combat.
-Changed getglobal() to _G[] as getglobal() has been deprecated.
Filename
RightClickSelfCast.lua
RightClickSelfCast.toc
diff --git a/RightClickSelfCast.lua b/RightClickSelfCast.lua
index 6fae405..abfd4f6 100644
--- a/RightClickSelfCast.lua
+++ b/RightClickSelfCast.lua
@@ -11,43 +11,66 @@ local bars = {
 "PossessBarFrame",
 }

-for i, v in ipairs(bars) do
-	local bar = getglobal(v)
-	bar:SetAttribute("unit2", "player")
-end
-
 local f = CreateFrame("frame","RightClickSelfCast",UIParent)
 f:SetScript("OnEvent", function(self, event, ...) self[event](self, ...) end)

+function f:PLAYER_REGEN_ENABLED()
+	self:PLAYER_LOGIN()
+	self:UnregisterEvent("PLAYER_REGEN_ENABLED")
+	self.PLAYER_REGEN_ENABLED = nil
+end
+
 function f:PLAYER_LOGIN()

-	--this is for the mod ExtraBar (Author: Cowmonster)
-	--http://www.wowinterface.com/downloads/info14492-ExtraBar.html
+	-- if we load/reload in combat don't try to set secure attributes or we get action_blocked errors
+	if InCombatLockdown() or UnitAffectingCombat("player") then
+		self:RegisterEvent("PLAYER_REGEN_ENABLED")
+		return
+	end
+
+	-- Blizzard bars
+	for i, v in ipairs(bars) do
+		local bar = _G[v]
+		bar:SetAttribute("unit2", "player")
+	end
+
+	-- this is for the mod ExtraBar (Author: Cowmonster)
+	-- http://www.wowinterface.com/downloads/info14492-ExtraBar.html
 	for id=1, 12 do
-		local button = getglobal("ExtraBarButton"..id)
+		local button = _G["ExtraBarButton"..id]
 		if button ~= nil then
 			button:SetAttribute("unit2", "player")
 		end
 	end

-	--this is for the mod ExtraBars (Author: Alternator)
-	--http://www.wowinterface.com/downloads/info13335-ExtraBars.html
+	-- this is for the mod ExtraBars (Author: Alternator)
+	-- http://www.wowinterface.com/downloads/info13335-ExtraBars.html
 	for id=1, 4 do
-		local frame = getglobal("ExtraBar"..id)
+		local frame = _G["ExtraBar"..id]
 		if frame ~= nil then
 			frame:SetAttribute("unit2", "player")
 			for bid=1, 12 do
-				local button = getglobal("ExtraBar"..id.."Button"..bid)
+				local button = _G["ExtraBar"..id.."Button"..bid]
 				if button ~= nil then
 					button:SetAttribute("unit2", "player")
 				end
 			end
 		end
 	end
-
+
+	-- ElvUI 3.05+ (Author: Elv22, TukUI fork)
+	-- http://www.wowinterface.com/downloads/info17749-ElvUI.html
+	local barID = 1
+	while _G["ElvUI_Bar"..barID] do
+		for	_,button in next,_G["ElvUI_Bar"..barID].buttons,nil do
+			button:SetAttribute("unit2", "player")
+		end
+		barID = barID+1
+	end
+
 	self:UnregisterEvent("PLAYER_LOGIN")
 	self.PLAYER_LOGIN = nil

 end

-if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end
\ No newline at end of file
+if IsLoggedIn() then f:PLAYER_LOGIN() else f:RegisterEvent("PLAYER_LOGIN") end
diff --git a/RightClickSelfCast.toc b/RightClickSelfCast.toc
index 437a3e3..2c62989 100644
--- a/RightClickSelfCast.toc
+++ b/RightClickSelfCast.toc
@@ -1,7 +1,7 @@
 ## Interface: 40300
 ## Title: RightClickSelfCast
 ## Author: Xruptor
-## Version:  1.9
+## Version:  2.0
 ## Notes: Makes all the Blizzard actionbars always self-cast on right-click (regardless of current target)

 RightClickSelfCast.lua
\ No newline at end of file