WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Modifying InteruptBar's display behavior (https://www.wowinterface.com/forums/showthread.php?t=42191)

litesung 12-22-11 12:22 AM

Modifying InteruptBar's display behavior
 
Hello, I'm new to .lua editing and was wondering if I could modify the behavior of InteruptBar by only showing the frame in PVP (Arenas, Battlegrounds, and possibly when flagged for PVP), similar to how Spy has the options to only show the frame in Arenas & BGs.

Is it possible for me to hard-code it into the .lua file?

Can anyone help me out? Thanks :)

jasje 12-22-11 09:51 AM

Lua Code:
  1. local instanceType = select(2, IsInInstance())
  2. if instanceType == "pvp" or instanceType == "arena" then
  3.     self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  4. else
  5.     self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  6. end

Not pro at coding but it's something like that

litesung 12-22-11 03:27 PM

I tried adding that to .lua in many forms, and I can't seem to get it right. Anymore help? :(

Vlad 12-23-11 06:24 AM

Just an idea:

Code:

local f = ? -- FrameReference not sure of the name

f:RegisterEvent("PLAYER_ENTERING_WORLD") -- register the event to run after each loading screen

f:HookScript("OnEvent", function(f, event) -- we only add this to the current function, instead of replacing it entirely (then we match the event to be what we expect, before we run our code)
  if event == "PLAYER_ENTERING_WORLD" then
    local instanceType = select(2, IsInInstance())
    if instanceType == "pvp" or instanceType == "arena" then
      f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    else
      f:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    end
  end
end)


litesung 12-23-11 12:17 PM

I'll test out that second code today. Hopefully it works this time x)

& btw thanks for the explanations of how each line works :) it will be easier for me to mess around with it now

Phanx 12-26-11 02:57 AM

InterruptBar does not give its frame a global name, so you cannot (easily) access it from outside of the addon's own Lua file. The following simple modification to InterruptBar.lua should work.

Find this line, near the end of the file:
Code:

        ["COMBAT_LOG_EVENT_UNFILTERED"] = function(self,...) InterruptBar_COMBAT_LOG_EVENT_UNFILTERED(...) end,
After it, add:
Code:

        ["ZONE_CHANGED_NEW_AREA"] = function(self)
                local _, instanceType = IsInInstance()
                if instanceType == "arena" or instanceType == "pvp" or (instanceType == "none" and GetZonePVPInfo() == "combat") then
                        self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
                        self:Show()
                else
                        self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
                        InterruptBar_ResetAllTimers()
                        self:Hide()
                end
        end,


litesung 12-30-11 05:34 AM

Quote:

Originally Posted by Phanx (Post 250075)
InterruptBar does not give its frame a global name, so you cannot (easily) access it from outside of the addon's own Lua file. The following simple modification to InterruptBar.lua should work.

Find this line, near the end of the file:
Code:

        ["COMBAT_LOG_EVENT_UNFILTERED"] = function(self,...) InterruptBar_COMBAT_LOG_EVENT_UNFILTERED(...) end,
After it, add:
Code:

        ["ZONE_CHANGED_NEW_AREA"] = function(self)
                local _, instanceType = IsInInstance()
                if instanceType == "arena" or instanceType == "pvp" or (instanceType == "none" and GetZonePVPInfo() == "combat") then
                        self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
                        self:Show()
                else
                        self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
                        InterruptBar_ResetAllTimers()
                        self:Hide()
                end
        end,


This worked perfectly :D

I typed "/ib hidden" to show the frame, and positioned it where I wanted it, then I hid it again by typing "/ib hidden". When I tested it, the frame was not showing, but the spell icons appear when they are being used!

This actually turned out better than I ever wanted! THANKS!!!


All times are GMT -6. The time now is 11:38 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI