TradesBar

CustomTradesBar.sample

Use at your own risk!

Notes

  • This file is run first, so if you don't encapsulate your code within the CustomTradesBar function, it may generate errors and behave unexpectedly.
  • CustomTradesBar() is called before adding in-game added spells and items to the bar.
  • CustomTradesBar takes no arguments (unless you hack TradesBar.lua).
  • CustomTradesBarFromFile gets added to the bar after adding in-game added spells and items to the bar.
  • All buttons added by the user (unless hacked into TradesBar.lua or if you add them directly to Trades with Trades['panel'] = 4) will be placed on the right-hand panel of the Admin frame.

Table Dissection

title
The text displayed on the mouseover or, in the case of items, the item name or item string. Short string ("item:itemid") is sufficient. If it is an item, it will not be added to the bar if it is not in your inventory. If you receive the item after loading the game, you must reload the UI to see the item on the bar. If the title does not match any item, spell, or skill, the button will not be added. This field is required for all buttons.
type
The only valid options for this are, "spell", "item", "macro", or "skill". This field is required for all buttons.
spell
Uses a secure button with "spell" as its "type" attribute.
item
Uses a secure button with "item" as its "type" attribute.
macro
Uses a secure button with "macrotext" as its "type" attribute. Requires macrotext (duh).
skill
Uses CastSpell(). This option should not be used unless the spell does not cause an action.
texture
The graphic to put on the button. This can be any valid graphic, even those from other addons. This field is only used for "macro" type buttons. If not included, your macro button will just be an ugly box.
macrotext
The macro to execute. This field is only used for "macro" type buttons.
tooltiptext
The text to display on the tooltip. If not given the title field will be used. This field is only used for "macro" type buttons.

Any other fields will be ignored.

Code Snipits

Here's a few things you can add to your CustomTradesBar.lua file. Feel free to add more via comments.

Required for all Snipits

-- This goes at the top of the file
CustomTradesBarFromFile = {}

Tracking Buttons

Known Issues

  • Does not play well with prof tracking abilities (Find Minerals, Find Herbs) or class tracking abilities (Track Undead, Track Demons, etc).
    • This has been fixed in v2.12.1.
function CustomTradesBar()
    local name, texture, active, category
    for i = 1, GetNumTrackingTypes() do
        name, texture, active, category = GetTrackingInfo(i)
        table.insert(CustomTradesBarFromFile,
            {
                title = name,
                type = 'macro',
                texture = texture,
                macrotext = '/run SetTracking('.. i ..')',
                tooltiptext = 'Set tracking to "'.. name ..'"',
            }
        )
    end
end

Hide UI

Warning

  • If you don't have a key bound to toggle showing/hiding the UI, you will have to reload or relog to show the UI.
function CustomTradesBar()
    local texture = '\\Interface\\Icons\\Whatever_Icon'
    table.insert(CustomTradesBarFromFile,
        {
            title = 'ToggleUI',
            type = 'macro',
            texture = texture,
            macrotext = '/run UIParent:Hide()',
            tooltiptext = 'Hide Interface',
        }
    )
end

You must login to post a comment. Don't have an account? Register to get one!