1. #1

    [lua] Register Event

    hi together,

    working on my actionbar textures, but somehow it doesn't work properly.
    so can anybody help me please

    Code:
    -- ACTIONBAR --
    ---------------------------------------------------
    local MyHazardBG = zInterfaceTextureTemplate(nil, UIParent, 1024, 64)
    MyHazardBG:SetPoint("BOTTOM",0,0)
    MyHazardBG:SetFrameLevel(0)
    
    MyHazardBG:RegisterEvent("UNIT_ENTERED_VEHICLE")
    MyHazardBG:RegisterEvent("UNIT_ENTERING_VEHICLE")
    MyHazardBG:RegisterEvent("UNIT_EXITED_VEHICLE")
    MyHazardBG:RegisterEvent("UNIT_EXITING_VEHICLE")
    
    --[[
    MyHazardBG:SetScript("OnEvent", function(frame, event, self)
        if event == "UNIT_ENTERING_VEHICLE" or "UNIT_ENTERED_VEHICLE" then
            MyHazardBG:Hide()
            end
    end) 
    ]]--
    MyHazardBG:SetScript("OnEvent", function(frame, event)
        if event == "UNIT_EXITING_VEHICLE" or "UNIT_EXITED_VEHICLE" then
            MyHazardBG:Show()
        elseif event == "UNIT_ENTERING_VEHICLE" or "UNIT_ENTERED_VEHICLE" then
            MyHazardBG:Hide()
            end
                
    end)
    
    local t = MyHazardBG:CreateTexture()
        t:SetParent(MyHazardBG)
        t:SetAllPoints(MyHazardBG)
        t:SetTexture("Interface\\Addons\\zMedia\\textures\\MyActionBar.tga")

  2. #2
    I think wowinterface is a better resource for such topic...

    local MyHazardBG = zInterfaceTextureTemplate(nil, UIParent, 1024, 64)
    MyHazardBG:SetPoint("BOTTOM",0,0)
    MyHazardBG:SetFrameLevel(0)

    local t = MyHazardBG:CreateTexture()
    t:SetParent(MyHazardBG)
    t:SetAllPoints(MyHazardBG)
    t:SetTexture("Interface\\Addons\\zMedia\\textures\\MyActionBar.tga")

    local function onEvent(event)
    if event == "UNIT_EXITING_VEHICLE" or "UNIT_EXITED_VEHICLE" then
    MyHazardBG:Show()
    elseif event == "UNIT_ENTERING_VEHICLE" or "UNIT_ENTERED_VEHICLE" then
    MyHazardBG:Hide()
    end
    end

    MyHazardBG.RegisterEvent("UNIT_ENTERED_VEHICLE", onEvent)
    MyHazardBG.RegisterEvent("UNIT_ENTERING_VEHICLE", onEvent)
    MyHazardBG.RegisterEvent("UNIT_EXITED_VEHICLE", onEvent)
    MyHazardBG.RegisterEvent("UNIT_EXITING_VEHICLE", onEvent)

  3. #3
    Code:
    if event == "UNIT_EXITING_VEHICLE" or "UNIT_EXITED_VEHICLE" then
    should be
    Code:
    if event == "UNIT_EXITING_VEHICLE" or event == "UNIT_EXITED_VEHICLE" then
    Code:
    elseif event == "UNIT_ENTERING_VEHICLE" or "UNIT_ENTERED_VEHICLE" then
    should be
    Code:
    elseif event == "UNIT_ENTERING_VEHICLE" or event == "UNIT_ENTERED_VEHICLE" then
    UI & AddOns expert | Interface & Macros moderator - My work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •