Page 1 of 1

Macro for Dual Gatherers

PostPosted: Mon Mar 14, 2016 10:16 pm
by tipsey
Hello, I chose to take herbalism and mining to start off with on this server and i searched for a long time to try and find a macro that would allow me to switch tracking between the two with one button.

I was unsuccessful, so I decided to make my own :D

/run local x=0 if GetTrackingTexture() =="Interface\\Icons\\Spell_Nature_Earthquake" then x=1 end if x==0 then CastSpellByName("Find Minerals") else CastSpellByName("Find Herbs") end

Enjoy :D

Re: Macro for Dual Gatherers

PostPosted: Tue Mar 15, 2016 8:47 pm
by cyklon
Why make it so complex?

/run if buffed("Find Herbs", 'player') then CastSpellByName("Find Minerals") else CastSpellByName("Find Herbs") end;

Re: Macro for Dual Gatherers

PostPosted: Wed Mar 16, 2016 12:29 am
by AfterAfterlife
cyklon wrote:Why make it so complex?

/run if buffed("Find Herbs", 'player') then CastSpellByName("Find Minerals") else CastSpellByName("Find Herbs") end;


I'm pretty sure Vanilla API doesn't have "buffed" function. Instead of that, use UnitBuff("unit", "buffName"). Example: UnitBuff("player", "Find Herbs").

By the way, can you make a timer that switches between Find Herbs/Minerals every 1 second?
E.g.:
Code: Select all
/run local f, t, e  = CreateFrame("FRAME"), GetTime(), 0; f:SetScript("OnUpdate", function() e = GetTime() - t; if e > 1 then t = GetTime(); if UnitBuff("player", "Find Herbs") then CastSpellByName("Find Minerals"); else CastSpellByName("Find Herbs"); end; end; end;);


If the code above is too big for regular macros, try this one:
Code: Select all
/run local f,t,e,c,g  = CreateFrame("FRAME"),GetTime(),0,CastSpellByName,GetTime f:SetScript("OnUpdate", function() e = g - t if e > 1 then t = g if UnitBuff("player", "Find Herbs") then c("Find Minerals") else c("Find Herbs") end end end)

Re: Macro for Dual Gatherers

PostPosted: Wed Mar 16, 2016 1:16 am
by cyklon
AfterAfterlife wrote:
cyklon wrote:Why make it so complex?

/run if buffed("Find Herbs", 'player') then CastSpellByName("Find Minerals") else CastSpellByName("Find Herbs") end;


I'm pretty sure Vanilla API doesn't have "buffed" function. Instead of that, use UnitBuff("unit", "buffName"). Example: UnitBuff("player", "Find Herbs").

By the way, can you make a timer that switches between Find Herbs/Minerals every 1 second?
E.g.:
Code: Select all
/run local f, t, e  = CreateFrame("FRAME"), GetTime(), 0; f:SetScript("OnUpdate", function() e = GetTime() - t; if e > 1 then t = GetTime(); if UnitBuff("player", "Find Herbs") then CastSpellByName("Find Minerals"); else CastSpellByName("Find Herbs"); end; end; end;);


If the code above is too big for regular macros, try this one:
Code: Select all
/run local f,t,e,c,g  = CreateFrame("FRAME"),GetTime(),0,CastSpellByName,GetTime f:SetScript("OnUpdate", function() e = g - t if e > 1 then t = g if UnitBuff("player", "Find Herbs") then c("Find Minerals") else c("Find Herbs") end end end)


been usingit since lvl 5,, works perfect

maby it depends on SuperMacro

Re: Macro for Dual Gatherers

PostPosted: Wed Mar 16, 2016 11:20 am
by Dreez
yes "buffed" does require supermacro

and I doubt that timer macro will work as CastSpellByName is protected to only work on keypresses not on timers or events

Re: Macro for Dual Gatherers

PostPosted: Wed Mar 16, 2016 2:19 pm
by AfterAfterlife
Dreez wrote:I doubt that timer macro will work as CastSpellByName is protected to only work on keypresses not on timers or events

Oh, thanks for clarifying me.

Re: Macro for Dual Gatherers

PostPosted: Wed Mar 16, 2016 9:24 pm
by Lebroski
If you don't use SuperMacro then this should work for you

Code: Select all
/run if n~= 1 then CastSpellByName("Find Herbs") n=1 else CastSpellByName("Find Minerals") n=0 ;end

Re: Macro for Dual Gatherers

PostPosted: Wed Mar 16, 2016 11:28 pm
by Dreez
Lebroski wrote:If you don't use SuperMacro then this should work for you

Code: Select all
/run if n~= 1 then CastSpellByName("Find Herbs") n=1 else CastSpellByName("Find Minerals") n=0 ;end

this however stops working properly if you press it more than once every 1.5 seconds