Mercurial > wow > oocdo
view OOCDo.lua @ 9:5e15478c7731 v4
v4
author | rowaasr13 |
---|---|
date | Tue, 10 Jan 2017 19:40:46 +0300 |
parents | 3b9bc71a1dd6 |
children | 088390bd4ab3 |
line wrap: on
line source
-- [AUTOLOCAL START] local CreateFrame = CreateFrame local InCombatLockdown = InCombatLockdown local SecureHandlerWrapScript = SecureHandlerWrapScript local print = print local type = type -- [AUTOLOCAL END] local frame_name = "OOCDo" local button = CreateFrame("Button", frame_name, nil, "SecureActionButtonTemplate,SecureHandlerMouseUpDownTemplate") button:SetAttribute("type", "macro") button:SetAttribute("macrotext", "") SecureHandlerWrapScript( button, -- frame "OnClick", -- script button, -- header 'return nil, "reset"', -- pre 'self:SetAttribute("type", "macro") self:SetAttribute("macrotext", "")' -- post ) --- Sets button to perform given macro text as-is. -- Sets button's .type to "macro" and .macrotext to given string verbatim -- @param command macro text to perform -- @param command2 same as command, if first argument is "taken" because of : call. function button.MacroText(command, command2) if command == button then command = command2 end if InCombatLockdown() then return end button:SetAttribute("type", "macro") button:SetAttribute("macrotext", command) end button.Macro = button.MacroText button.T = button.MacroText button.M = button.MacroText --- Tries to set button to use first available item from list. -- Sets button's .type to "item" and .item to first item that player have (GetItemCount > 0). -- Returns if any item was found or not, so you can use this in conditional to do something else if there were no suitable items. -- If none of items was found, button will still lose previously assigned command. -- @param ... list of item IDs to try -- @return true if any item was found and nil otherwise function button.Use(...) if InCombatLockdown() then return end button:SetAttribute("type", "item") button:SetAttribute("item", nil) for idx = 1, select('#', ...) do repeat local elem = select(idx, ...) if elem == button then break end if type(elem) == "number" then if GetItemCount(elem) > 0 then button:SetAttribute("item", "item:" .. elem) return true end end until true end end --- Tries to set button to castwe first available spell from list. -- Sets button's .type to "spell" and .spell to first spell that player knowns (GetSpellInfo(name) returns something). -- Returns if any spell was found or not, so you can use this in conditional to do something else if there were no suitable spells. -- If none of spells was found, button will still lose previously assigned command. -- @param ... list of spell IDs to try -- @return true if any spell was found and nil otherwise function button.Cast(...) if InCombatLockdown() then return end button:SetAttribute("type", "spell") button:SetAttribute("spell", nil) for idx = 1, select('#', ...) do repeat local elem = select(idx, ...) if elem == button then break end if type(elem) == "number" then if GetSpellInfo(GetSpellInfo(elem)) then button:SetAttribute("spell", elem) return true end end until true end end