Maintenance for the week of December 23:
• NA megaservers for maintenance – December 23, 4:00AM EST (9:00 UTC) - 9:00AM EST (14:00 UTC)
• EU megaservers for maintenance – December 23, 9:00 UTC (4:00AM EST) - 14:00 UTC (9:00AM EST)

Info / Addon request - fade UI elements based on combat state

Awdwyn
Awdwyn
✭✭✭
Hi all, I'm completely new to lua, but have programming experience in other languages so I can generally get the jist of things if I have a good starting point.

I'd like to be able to fade (animate transition the opacity to 0) certain UI elements in combat, and then return them to default opacity out of combat, for example:
  • Wykkyd's quest tracker
  • Vampire status addon (adds a small icon and text indicator of stage)
  • Default compass

I'm happy to modify lua files for the two addons for my own use (and then provide my files to the authors in the event they want to implement the features themselves) however I believe I'd need to write (or somebody else could) a small addon to hide the compass in combat.

I know addons can track combat state (addons can auto sheathe weapons when combat ends) and modify the properties of UI elements (azurah) but as I'm unfamiliar with lua I'm not sure where to start here.

Any advice or help on where to start learning would be appreciated, or if somebody wants to tackle this idea that'd be great too.

Cheers!
  • Garkin
    Garkin
    ✭✭✭
    How to track combat state:
    local function OnCombatState(eventCode, inCombat)
       if inCombat then
          COMPASS_FRAME_FRAGMENT:Hide(1000)
       else
          COMPASS_FRAME_FRAGMENT:Show(1000)
       end
    end
    
    EVENT_MANAGER:RegisterForEvent("SomeUniqueName", EVENT_PLAYER_COMBAT_STATE, OnCombatState)
    

    The same way as above you can show or hide any HUD fade scene fragment. I don't know names of top level windows used by your addons, but in general you have to create fragment, add it to the scene where it should be visible:
    local fragment = ZO_HUDFadeSceneFragment:New(yourTopLevelWindow, showDuration, hideDuration)
    HUD_SCENE:AddFragment(fragment)
    
    and then call fragment:Show() or fragment:Hide() method when combat state changes. If you use number in show or hide method, it is custom duration of fade effect in milliseconds.


    EDIT:
    changed code to to use fade in/out animation, added information about scene fragments.

    A few words about scene fragments:
    http://www.esoui.com/portal.php?&id=27&pageid=12
    Edited by Garkin on July 30, 2014 8:22PM
    Garkin / EU / CSF guild
    My addons: SkyShards, LoreBooks, Dustman, Map Coordinates, No, thank you, ... (full list)
    I'm taking care of: Azurah - Interface Enhanced, Srendarr - Aura, Buff & Debuff Tracker and more
    My folder with updated/modified addons: DROPBOX
  • Awdwyn
    Awdwyn
    ✭✭✭
    Garkin wrote: »
    How to track combat state:
    local function OnCombatState(eventCode, inCombat)
          ZO_CompassFrame:SetAlpha(inCombat and 0 or 1)
    end
    
    EVENT_MANAGER:RegisterForEvent("SomeUniqueName", EVENT_PLAYER_COMBAT_STATE, OnCombatState)
    

    Awesome, thanks for the pointer :D I'm guessing that using the same principle, and by identifying the object name for a custom object/frame (such as from another addon) I could adjust their alpha value as well.

    Are addon UI frames local scope or accessible to other addons via some kind of namespace?
  • Garkin
    Garkin
    ✭✭✭
    Awdwyn wrote: »
    Garkin wrote: »
    How to track combat state:
    local function OnCombatState(eventCode, inCombat)
          ZO_CompassFrame:SetAlpha(inCombat and 0 or 1)
    end
    
    EVENT_MANAGER:RegisterForEvent("SomeUniqueName", EVENT_PLAYER_COMBAT_STATE, OnCombatState)
    

    Awesome, thanks for the pointer :D I'm guessing that using the same principle, and by identifying the object name for a custom object/frame (such as from another addon) I could adjust their alpha value as well.

    Are addon UI frames local scope or accessible to other addons via some kind of namespace?
    - I have changed code to use fade/in out animations.
    - The easiest way how to get names of UI elements is using the Zgoo addon (official link, my modified version)
    Garkin / EU / CSF guild
    My addons: SkyShards, LoreBooks, Dustman, Map Coordinates, No, thank you, ... (full list)
    I'm taking care of: Azurah - Interface Enhanced, Srendarr - Aura, Buff & Debuff Tracker and more
    My folder with updated/modified addons: DROPBOX
  • Awdwyn
    Awdwyn
    ✭✭✭
    Garkin wrote: »
    Awdwyn wrote: »
    Garkin wrote: »
    How to track combat state:
    local function OnCombatState(eventCode, inCombat)
          ZO_CompassFrame:SetAlpha(inCombat and 0 or 1)
    end
    
    EVENT_MANAGER:RegisterForEvent("SomeUniqueName", EVENT_PLAYER_COMBAT_STATE, OnCombatState)
    

    Awesome, thanks for the pointer :D I'm guessing that using the same principle, and by identifying the object name for a custom object/frame (such as from another addon) I could adjust their alpha value as well.

    Are addon UI frames local scope or accessible to other addons via some kind of namespace?
    - I have changed code to use fade/in out animations.
    - The easiest way how to get names of UI elements is using the Zgoo addon (official link, my modified version)

    Thanks for the detailed replies! I'll have to give this a shot tonight after work.
Sign In or Register to comment.