Thread Tools Display Modes
01-11-12, 05:34 AM   #1
whoarrior
A Deviate Faerie Dragon
 
whoarrior's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 14
macro behaviour dependent from location

Hi guys,

i'm looking for a macro which does different things depending on if i'm in the arena or not.

e.g.
inside the arena -> dispel magic
anywhere else -> pom
Code:
/cast [@arena1,noexists] Prayer of Mending
/stopmacro [@arena1,noexists]
/cast [mod,@player][@party1,nodead][] Dispel Magic
Any ideas, or do i need an addon which switchs macros when entering/leaving arenas?

(:

Last edited by whoarrior : 01-11-12 at 05:37 AM.
  Reply With Quote
01-11-12, 04:37 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Since you want the macro to cast a spell (rather than perform some other action that does not take a target from the macro) you cannot use the @unit conditional unless you only want to cast Dispel Magic on the arena1 unit. If you simply want the button to become a normal Dispel Magic button inside arenas, you would need to use an addon that changed the macro when you entered an arena.
  Reply With Quote
01-11-12, 07:08 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
-- This needs to match your macro's name:
local macroName = "MacroNameHere"

-- Edit these as desired:
local arenaMacro = "/cast [mod, @player] [@party1, nodead] [] Dispel Magic"
local otherMacro = "/cast Prayer of Mending"

-- Don't edit anything below here. -------------------------------------

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function()
	local macroID = GetMacroIndexByName( "NAME_HERE" )
	if macroID then
		local _, instanceType = IsInInstance()
		local macroText
		if instanceType == "arena" then
			macroText = arenaMacro
		else
			macroText = otherMacro
		end
		EditMacro(macroID, macroName, "INV_Misc_QuestionMark", macroText, 1, 1)
		DEFAULT_CHAT_FRAME:AddMessage(string.format("%s macro updated.", macroName))
	else
		DEFAULT_CHAT_FRAME:AddMessage(string.format("%s macro not found!", macroName))
	end
end)

Last edited by Phanx : 01-16-12 at 05:18 AM.
  Reply With Quote
01-12-12, 04:51 AM   #4
whoarrior
A Deviate Faerie Dragon
 
whoarrior's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 14
Looks great, i will try it at home. Thank you!

(:
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » macro behaviour dependent from location

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