View Single Post
12-28-15, 11:42 AM   #4
Meloric
A Deviate Faerie Dragon
Join Date: Mar 2005
Posts: 14
Sorry for the delay in answering, pretty hectic the last week or so with the holidays.

Here's the code for the Local Funcion part of the CEBcore.lua. I bolded and intalicized the error line since line numbers don't show in my cut of the code. The entire lua code is 354 lines. If that is needed I can repost all of it.


Code:
local function RegEventsHandler(self, event, ...)

	if event == "PLAYER_LOGIN" then
		ChiEnergyBar:PlayerLogin()
		ChiEnergyBar.eventHandler:UnregisterEvent("PLAYER_LOGIN")
		ChiEnergyBar.eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
		ChiEnergyBar.eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
	elseif  event == "PLAYER_REGEN_DISABLED" or event == "PLAYER_REGEN_ENABLED" then
		ChiEnergyBar:UpdateBar()
		if ChiEnergyBarDB.ebEnable then
			if ChiEnergyBarDB.ebShowOnlyInCombat then
				if UnitAffectingCombat("player") then
					-- in combat
					locDB.inCombat = true
					EnergyBar:Show()
				else
					-- not in combat
					locDB.inCombat = false
					EnergyBar:Hide()
				end
			end
		end
		if ChiEnergyBarDB.cpEnable then
			if ChiEnergyBarDB.cpShowOnlyInCombat then
				if UnitAffectingCombat("player") then
					-- in combat
					locDB.inCombat = true
					ChiPointsBar:Show()
				else
					-- not in combat
					locDB.inCombat = false
					ChiPointsBar:Hide()
				end
			end
		end
		if ChiEnergyBarDB.tbEnable then
			if ChiEnergyBarDB.tbShowOnlyInCombat then
				if UnitAffectingCombat("player") then
					-- in combat
					locDB.inCombat = true
					TBBar:Show()
				else
					-- not in combat
					locDB.inCombat = false
					TBBar:Hide()
				end
			end
		end
	elseif event == "UNIT_ENTERED_VEHICLE" then
		ChiEnergyBar.eventHandler:UnregisterEvent("UNIT_ENTERED_VEHICLE")
		ChiEnergyBar.eventHandler:RegisterEvent("UNIT_EXITED_VEHICLE")
		local unit = select(1, ...)
		if unit == "player" then
			local inVehicle, hasVehicleUI = UnitInVehicle(unit), UnitHasVehicleUI(unit)
			if inVehicle and hasVehicleUI then
				EnergyBar:Hide()
				ChiPointsBar:Hide()
				TBBar:Hide()
			end
		end
	elseif event == "UNIT_EXITED_VEHICLE" then
		ChiEnergyBar.eventHandler:UnregisterEvent("UNIT_EXITED_VEHICLE")
		ChiEnergyBar.eventHandler:RegisterEvent("UNIT_ENTERED_VEHICLE")
		ChiEnergyBar:UpdateBar()
		local unit = select(1, ...)
		if unit == "player" then
			ChiEnergyBar:UpdateBar()
			if ChiEnergyBarDB.ebEnable then
				if ChiEnergyBarDB.ebShowOnlyInCombat then
					EnergyBar:Hide()
				else
					EnergyBar:Show()
				end
			else
				Energybar:Hide()
			end
			if ChiEnergyBarDB.cpEnable then
				if ChiEnergyBarDB.cpShowOnlyInCombat then
					ChiPointsBar:Hide()
				else
					ChiPointsBar:Show()
				end
			else
				ChiPointsBar:Hide()
			end
			if ChiEnergyBarDB.tbEnable then
				if ChiEnergyBarDB.tbShowOnlyInCombat then
					TBBar:Hide()
				else
					TBBar:Show()
				end
			else
				TBBar:Show()
			end
		end
	elseif event == "PET_BATTLE_OPENING_START" then
		ChiEnergyBar.eventHandler:UnregisterEvent("PET_BATTLE_OPENING_START")
		ChiEnergyBar.eventHandler:RegisterEvent("PET_BATTLE_CLOSE")
		EnergyBar:Hide()
		ChiPointsBar:Hide()
		TBBar:Hide()
	elseif event == "PLAYER_ENTERING_WORLD" or event == "PET_BATTLE_CLOSE" then
		if event == "PET_BATTLE_CLOSE" then
			ChiEnergyBar.eventHandler:UnregisterEvent("PET_BATTLE_CLOSE")
			ChiEnergyBar.eventHandler:RegisterEvent("PET_BATTLE_OPENING_START")
		end
		ChiEnergyBar:UpdateBar()
		if ChiEnergyBarDB.ebEnable then
			if ChiEnergyBarDB.ebShowOnlyInCombat then
				EnergyBar:Hide()
			else
				EnergyBar:Show()
			end
		else
			EnergyBar:Hide()
		end
		if ChiEnergyBarDB.cpEnable then
			if ChiEnergyBarDB.cpShowOnlyInCombat then
				ChiPointsBar:Hide()
			else
				ChiPointsBar:Show()
			end
		else
			ChiPointsBar:Hide()
		end
		if ChiEnergyBarDB.tbEnable then
			if ChiEnergyBarDB.tbShowOnlyInCombat then
				TBBar:Hide()
			else
				TBBar:Show()
			end
		else
			TBBar:Hide()
		end
	elseif event == "PLAYER_TALENT_UPDATE" or event == "ACTIVE_TALENT_GROUP_CHANGED" then
		local _, _, _, _, _, hasAscension = GetTalentInfo(8)
		if hasAscension then
			locDB.cpMax = locDB.cpTot
		else
			locDB.cpMax = locDB.cpTot - 1
		end
		locDB.cpUpdate = true
		locDB.doChiPointsUpdate = true
		ChiEnergyBar:HandleChiPointFrames(locDB.cpMax, true)
		ChiEnergyBar:UpdateBar()
	elseif event == "UNIT_POWER" or event == "UNIT_AURA" then
		local unit = select(1, ...)
		if unit == "player" then
			ChiEnergyBar:UpdateBar()
		end
	end
  Reply With Quote