Quantcast Multiple line macros using the macrotext attribute of a SecureActionButtonTemplate? - WoWInterface
Thread Tools Display Modes
02-02-19, 12:14 AM   #1
Nightness
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 19
Multiple line macros using the macrotext attribute of a SecureActionButtonTemplate?

I'm looking to make a multi-line macro (and have it work) in my MagnetButtons addon, that uses SecureActionButtonTemplate. I would rather not do what addons like VuhDo do and create actual character macros to do multi-line macros (I assume that's why they are there). Is there any way to have multiple macro calls in a single macrotext attribute?

Edit: What format do I use for newlines, that works in this case?

/cleartarget
/stopcasting
/script ToggleGameMenu(); StaticPopup1:Hide()

Last edited by Nightness : 02-02-19 at 12:38 AM.
  Reply With Quote
02-02-19, 07:23 AM   #2
kurapica.igas
A Flamescale Wyrmkin
Join Date: Aug 2011
Posts: 101
Just use the '\n' between each lines.
  Reply With Quote
02-02-19, 08:28 AM   #3
Nightness
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 19
Originally Posted by kurapica.igas View Post
Just use the '\n' between each lines.
Tried '\n', and "|n", and \013\010 already.
  Reply With Quote
02-02-19, 10:13 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,006
Do you mean something like:
Lua Code:
  1. local button = CreateFrame('Button', 'ExitButton', nil, "InsecureActionButtonTemplate, UIPanelButtonTemplate")
  2. button:SetText("Logout")
  3. button:SetAttribute('type', 'macro')
  4. button:SetPoint("CENTER")
  5. button:SetSize(60, 24)
  6. SLASH_MCR1 = "/mcr"
  7. SlashCmdList["MCR"] = function(msg)
  8.     button:SetAttribute('macrotext', string.gsub(msg, '\92n', '\n'))
  9.     print(button:GetAttribute('macrotext'))
  10. end

Slash:
Code:
/mcr /cleartarget\n/stopcasting\n/script ToggleGameMenu(); StaticPopup1:Hide()
I might not be understanding properly what you are trying to achieve.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
02-02-19, 04:21 PM   #5
Vrul
A Frostmaul Preserver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 297
As mentioned "\n" will work:
Code:
local macrotext = "/cleartarget\n/stopcasting\n/script ToggleGameMenu(); StaticPopup1:Hide()"
or you could use a literal string:
Code:
local macrotext = 
[[/cleartarget
/stopcasting
/script ToggleGameMenu(); StaticPopup1:Hide()]]
Keep in mind that you cannot have any spaces in front of a slash command's slash or it won't work. To get around that you can use:
Code:
local addonName = ...

local function CreateMacro(name, macrotext)
	name = ("%sMacro-%s"):format(addonName, name)
	local frame = _G[name]
	if not frame then
		frame = CreateFrame('Button', name, nil, 'SecureActionButtonTemplate')
		frame:SetAttribute('type', 'macro')
	end
	frame:SetAttribute('macrotext', macrotext:trim():gsub("%s+", " "):gsub(" /", "\n/"))
	return name
end

CreateMacro("Menu", [[
	/cleartarget
	/stopcasting
	/script ToggleGameMenu(); StaticPopup1:Hide()
]])
If "\n" didn't work then you have something else working against you so post your code.
  Reply With Quote
02-02-19, 09:12 PM   #6
Nightness
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 19
Originally Posted by Fizzlemizz View Post
Do you mean something like:
Lua Code:
  1. local button = CreateFrame('Button', 'ExitButton', nil, "InsecureActionButtonTemplate, UIPanelButtonTemplate")
  2. button:SetText("Logout")
  3. button:SetAttribute('type', 'macro')
  4. button:SetPoint("CENTER")
  5. button:SetSize(60, 24)
  6. SLASH_MCR1 = "/mcr"
  7. SlashCmdList["MCR"] = function(msg)
  8.     button:SetAttribute('macrotext', string.gsub(msg, '\92n', '\n'))
  9.     print(button:GetAttribute('macrotext'))
  10. end

Slash:
Code:
/mcr /cleartarget\n/stopcasting\n/script ToggleGameMenu(); StaticPopup1:Hide()
I might not be understanding properly what you are trying to achieve.
The gsub worked perfectly, thanks!!!
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Multiple line macros using the macrotext attribute of a SecureActionButtonTemplate?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off