View Single Post
02-02-19, 04:21 PM   #5
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
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