WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   secure actionbutton macrotext and modifiers (https://www.wowinterface.com/forums/showthread.php?t=52975)

saxitoxin 12-12-15 06:58 PM

secure actionbutton macrotext and modifiers
 
How do I add a modifier to a secure actionbutton macrotext?

what I want to do is make my mount macro into a addon, but I cant get the [mod] command to read

mount macro code
Code:

#showtooltip
/cancelform
/leavevehicle
/stopcasting
/cast [mod:shift] Traveler's Tundra Mammoth ; [mod:ctrl] Azure Water Strider ; [mod:alt] Obsidian Nightwing
/run if SecureCmdOptionParse"[nomod]"then C_MountJournal.Summon(0)end

my testcode to see that [mod] is not working

yes, I know that I should post the entire code, but it is such a horrible mess right now so I made this one instead to describe my problem
Lua Code:
  1. local HSframe = CreateFrame("BUTTON","homeButton", UIParent, "SecureActionButtonTemplate")
  2. HSframe:SetPoint("CENTER")
  3. HSframe:SetSize(42, 16)
  4. HSframe:EnableMouse(true)
  5. HSframe:RegisterForClicks("AnyUp")
  6. HSframe:SetAttribute("type1", "macro")
  7. HSframe:SetAttribute("macrotext", "/use [mod] item:128353; item:6948")
  8.  
  9. HSframe.icon = HSframe:CreateTexture(nil,"OVERLAY",nil,7)
  10. HSframe.icon:SetSize(16, 16)
  11. HSframe.icon:SetPoint("LEFT")
  12. HSframe.icon:SetTexture(1,1,0)
  13.  
  14. HSframe.text = HSframe:CreateFontString(nil, "OVERLAY")
  15. HSframe.text:SetFont(STANDARD_TEXT_FONT, 16, "THINOUTLINE")
  16. HSframe.text:SetPoint("RIGHT")
  17. HSframe.text:SetText("HS")

semlar 12-12-15 07:57 PM

It doesn't work because SetAttribute("type1", "macro") explicitly means it's only a "macro" for unmodified left-clicks, you probably just want "type" in there (or "*type1" for any left-clicks).

Phanx 12-16-15 01:22 AM

Just use "type" without any numbers, asterisks, or modifiers.

Code:

local button = CreateFrame("Button", "MyAwesomeMountButton", nil, "SecureActionButtonTemplate")
button:SetAttribute("type", "macro")

button:SetAttribute("macrotext", [[
    /cancelform
    /leavevehicle
    /stopcasting
    /cast [mod:shift] Traveler's Tundra Mammoth ; [mod:ctrl] Azure Water Strider ; [mod:alt] Obsidian Nightwing
    /stopmacro [mod]
    /run C_MountJournal.Summon(0)
]])

-- add visual stuff here

SetOverrideBinding(button, false, "CTRL+`", "CLICK MyAwesomeMountButton:LeftButton")

See also:
https://github.com/Phanx/MountMe/blob/master/Addon.lua


All times are GMT -6. The time now is 06:09 AM.

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