View Single Post
08-07-18, 07:49 PM   #15
joeyo
An Aku'mai Servant
Join Date: Jan 2012
Posts: 31
Originally Posted by Vrul View Post
Are you sure another addon or another section of your addon isn't doing it? By default PetFrame is parented to PlayerFrame so if the PlayerFrame is hidden then the PetFrame should also be hidden.

Edit:
If your PetFrame is not parented to PlayerFrame like it seems then you will need to add <frame>:RegisterUnitEvent("UNIT_PET", "player") to your event handler and add code to deal with that event.
EDIT:!!your a genius sir the one line that was missing is something i didnt try! all i needed to add was
Code:
PlayerUnitFrame:RegisterUnitEvent("UNIT_PET", "player");
at the end of it all and it worked!
now is there anyway to combine addons together?
this is to show player frame when in combat or with a target or not at full health.it also hides the texture of the frame and also the player level
Code:
-- This file is loaded from "!frame fade.toc"

--[[
	Stripped from ImprovedBlizzardUI by Theroxis
	Modified to ONLY hide/unhide the player frame.
    modules\frames\player.lua
    Styles, Scales and Repositions the Player Unit Frame.
    Disables Player Portrait Spam
]]

local PlayerUnitFrame = CreateFrame('Frame', nil, UIParent);  
local ForceShown = false
--[[
    Hides the Player Frame when you are out of combat, have no target and are at full health.

    @ param boolean $hide Should we hide the frame
    @ return void
]]

local function HidePlayer(hide)
    if (InCombatLockdown() == false) then
        if (hide and UnitHealth('player') == UnitHealthMax('player') and UnitExists('target') == false and (not ForceShown)) then
            PlayerFrame:Hide();
        else
            PlayerFrame:Show();
        end
    end
end


--[[
    Handles the WoW API Events Registered Below

    @ param Frame $self The Frame that is handling the event 
    @ param string $event The WoW API Event that has been triggered
    @ param arg $... The arguments of the Event
    @ return void
]]

local function HandleEvents (self, event, ...)
    if (event == 'PLAYER_ENTERING_WORLD' or event == 'PLAYER_LOGIN' or event == 'ADDON_LOADED') then
        HidePlayer(true);
    end

    if (event == 'PLAYER_REGEN_DISABLED') then
        HidePlayer(false);
    elseif (event == 'PLAYER_REGEN_ENABLED' or event == 'UNIT_HEALTH') then
        HidePlayer(true);
    end

    if (event == 'PLAYER_TARGET_CHANGED') then
        if (UnitExists('target')) then
            HidePlayer(false);
        else
            HidePlayer(true);
        end
    end

    if (event == 'UNIT_EXITED_VEHICLE' and ... == 'player') then
        StyleFrames();
    end


end

function TogglePlayerFrameHide()
	ForceShown = not ForceShown
	DEFAULT_CHAT_FRAME:AddMessage(ForceShown)
	HidePlayer(true)
end

    local f = CreateFrame("Frame")    --we need a frame to listen for an event
    f:RegisterEvent("PLAYER_ENTERING_WORLD")   --we'll listen for this event - all the UI stuff should be done loading by now
    f:SetScript("OnEvent", function(self, event)   --when the event fires we want this to happen
         PlayerFrameTexture:Hide();
         PlayerLevelText:Hide()
    end)

-- Register the Modules Events
PlayerUnitFrame:SetScript('OnEvent', HandleEvents);
PlayerUnitFrame:RegisterEvent('PLAYER_ENTERING_WORLD');
PlayerUnitFrame:RegisterEvent('PLAYER_LOGIN');
PlayerUnitFrame:RegisterEvent('UNIT_HEALTH');
PlayerUnitFrame:RegisterEvent('PLAYER_REGEN_DISABLED');
PlayerUnitFrame:RegisterEvent('PLAYER_REGEN_ENABLED');
PlayerUnitFrame:RegisterEvent('PLAYER_TARGET_CHANGED');
PlayerUnitFrame:RegisterEvent('UNIT_EXITED_VEHICLE');
PlayerUnitFrame:RegisterEvent('ADDON_LOADED');
this addon does chat/minimap buttons/removes the target/pet frame textures/removes the pet mana bar and also sets the target cast bar on a different parent.
Code:
-- This file is loaded from "!chat.toc"

CHAT_TAB_SHOW_DELAY = 0
CHAT_TAB_HIDE_DELAY = 0
CHAT_FRAME_FADE_TIME = 0
CHAT_FRAME_FADE_OUT_TIME = 0
DEFAULT_CHATFRAME_ALPHA = 0
ChatFrame1:SetTimeVisible(5)
ChatFrame1:SetFadeDuration(3)
MiniMapMailFrame:SetParent(UIParent)
MiniMapMailFrame:SetAlpha(0.4)
QueueStatusMinimapButton:SetParent(UIParent)
QueueStatusMinimapButton:SetAlpha(0.4)
GameTimeFrame:SetParent(UIParent)
GameTimeFrame:SetAlpha(0.4)
GarrisonLandingPageMinimapButton:SetParent(UIParent)
GarrisonLandingPageMinimapButton:SetAlpha(0.4)
MiniMapTracking:SetParent(UIParent)
MiniMapTracking:SetAlpha(0.4)
TargetFrameSpellBar:SetParent(UiParent)
TargetFrameTextureFrameTexture:Hide()
PetFrameManaBar:SetScript("OnShow", PetFrameManaBar.Hide)
PetFrameTexture:Hide()
and this removes the target and focus frame level
Code:
local f=CreateFrame("Frame")
f:SetScript("OnEvent",function(self,event,...)
  if event=="PLAYER_TARGET_CHANGED" then
    -- do TargetFrame changes here
    TargetFrameTextureFrameLevelText:Hide()
  elseif event=="PLAYER_FOCUS_CHANGED" then
    -- do FocusFrame changes here
    FocusFrameTextureFrameLevelText:Hide()
  end
end)
f:RegisterEvent("PLAYER_TARGET_CHANGED")
f:RegisterEvent("PLAYER_FOCUS_CHANGED")
i want to combine all these with the now working pet lua
Code:
-- This file is loaded from "!frame combat.toc"

local PlayerUnitFrame = CreateFrame('Frame', nil, UIParent);  
local ForceShown = false
--[[
    Hides the Pet Frame when you are out of combat, have no target and are at full health.

    @ param boolean $hide Should we hide the frame
    @ return void
]]

local function HidePet(hide)
    if (InCombatLockdown() == false) then
        if (hide and UnitHealth('pet') == UnitHealthMax('pet') and UnitExists('target') == false and (not ForceShown)) then
            PetFrame:Hide();
        else
            PetFrame:Show();
        end
    end
end


--[[
    Handles the WoW API Events Registered Below

    @ param Frame $self The Frame that is handling the event 
    @ param string $event The WoW API Event that has been triggered
    @ param arg $... The arguments of the Event
    @ return void
]]

local function HandleEvents (self, event, ...)
    if (event == 'PLAYER_ENTERING_WORLD' or event == 'PLAYER_LOGIN' or event == 'ADDON_LOADED' or event == 'UNIT_PET') then
        HidePet(true);
    end

    if (event == 'PLAYER_REGEN_DISABLED') then
        HidePet(false);
    elseif (event == 'PLAYER_REGEN_ENABLED' or event == 'UNIT_HEALTH') then
        HidePet(true);
    end

    if (event == 'PLAYER_TARGET_CHANGED') then
        if (UnitExists('target')) then
            HidePet(false);
        else
            HidePet(true);
        end
    end

    if (event == 'UNIT_EXITED_VEHICLE' and ... == 'pet') then
        StyleFrames();
    end


end

function TogglePetFrameHide()
	ForceShown = not ForceShown
	DEFAULT_CHAT_FRAME:AddMessage(ForceShown)
	HidePet(true)
end

-- Register the Modules Events
PlayerUnitFrame:SetScript('OnEvent', HandleEvents);
PlayerUnitFrame:RegisterEvent('PLAYER_ENTERING_WORLD');
PlayerUnitFrame:RegisterEvent('PLAYER_LOGIN');
PlayerUnitFrame:RegisterEvent('UNIT_HEALTH');
PlayerUnitFrame:RegisterEvent('PLAYER_REGEN_DISABLED');
PlayerUnitFrame:RegisterEvent('PLAYER_REGEN_ENABLED');
PlayerUnitFrame:RegisterEvent('PLAYER_TARGET_CHANGED');
PlayerUnitFrame:RegisterEvent('UNIT_EXITED_VEHICLE');
PlayerUnitFrame:RegisterEvent('ADDON_LOADED');
PlayerUnitFrame:RegisterUnitEvent("UNIT_PET", "player");
PlayerUnitFrame:RegisterEvent('ADDON_LOADED');
seems everytime i try to combine something it just breaks the whole thing so if the lua masters can help me minimize the amount of addons i have id reeeeeally appreciate it =) i really have learned so much from this little problem though.

Last edited by joeyo : 08-07-18 at 08:18 PM.
  Reply With Quote