Macro for Gathering - Mining + Herbalism

Macro sent in by Jonathan for gathering both mining and herbalism nodes at the same time:
/run if not THO then local f,t,c=CreateFrame("Frame","THO"),1,0 f:SetScript("OnUpdate", function(_, e) c=c+e if c>3 then c=0 SetTracking(t) if t==1 then t=2 else t=1 end end end) THO:Hide() end
/run if THO:IsVisible() then THO:Hide() else THO:Show() end
Since this is obviously not a "read what it says" macro... it alternates back and forth between "Find Herbs" and "Find Minerals" every 3 seconds. Now, in one route around Arathi, I can herb and mine at the same time without losing a beat.

Thank you Jonathan for the email! Hope this helps anyone else who has the painstaking task of both mining and herbing at the same time.

11 comments: on "Macro for Gathering - Mining + Herbalism"

  1. I'd like to see this explained to me like I'm a six-year-old :-)

  2. I am so jealous of your ability to write that code.
    But it makes me wonder why doesn't wow understand people want both and make it available.
    Nice job coding.

  3. Let me take a crack at it anonymous...
    if the THO exists then create three local variables:
    f = new frame called "frame" on THO
    t = 1 (mining-1 or herbing-2)
    c = 0 (I believe this is to keep the mining or herbing frame visible for 3 seconds each time so it isn't blinking the nodes)
    if the THO frame does exist then OnUpdate cycle through mining or herbing (the value of t) and update t to alternate between 1 and 2
    Alternate between showing and hiding the THO

    I'm not an expert in the LUA so I may have made some mistakes but that is the general idea behind it

  4. Maybe I can help to put this straight:

    If not THO then
    - this means, if nothing called "THO" exists, then the macro does the following, else it will jump to the corresponding "end"

    local f,t,c=CreateFrame("Frame","THO"),1,0
    - next the macro creates three local (aka. only used in this macro) variables with the following input:
    f becomes a new frames (although it will not be displayed
    t becomes 1 (this will set the gathering type)
    c becomes 2 (c will be the counter)

    f:SetScript("OnUpdate", function(_, e)
    - now the new frame gets a script. everytime a new frame (as in framerate...screenframe) is shown, the function will be called (remember common framerates are 20-40 frames per second...)
    (I have to admit, I don't get the "_,e", I suppose it saves the frames since last call in e (1 most of the time...if there is no lag))

    c=c+e
    - obvious mathematic algorithm...just add the frames since last call (my assumption) to the counter "c".

    if c>3 then
    - if the counter "c" is bigger than 3, the macro continues with the following, else it will jump to the corresponding "end".

    c=0
    - reset of the counter

    SetTracking(t)
    - Set the Tracking to the trackingtype saved in variable "t" (1 on first run)

    if t==1 then t=2 else t=1 end
    - If the trackingtype "t" is 1 then let "t" become 2 otherwise it will become 1 (if it was 2) (this will swap the type between 1 and 2 everytime it switches the type)

    end end
    - close all if-functions

    THO:Hide()
    - hide the frame, so nothing can be seen but is still present
    (and if it's present, the function gets called with every frame, so it doesn't stop with the macro)

    /run if THO:IsVisible() then THO:Hide() else THO:Show() end
    - this simply runs every time you call the macro. If the frame "THO" is visible then hide, else it will be shown. This line is not necessary for the function to work (you can delete it if you want)
    (test it yourself...just push the macro again and again)

    This might not be simple enough for a six-year-old but it should help even non-programmer to understand it easily

    Best regards
    Luzianus

  5. Your analysis is basically on point there, Markco. It's like a tiny addon contained within a macro.

    It's clever, but where this falls down - along with most methods for switching tracking methods - is that 1 is not necessarily always Find Minerals, 2 is not always Find Herbs. The ID is actually assigned by the game based entirely on the order that they appear on the popup tracking list by the minimap.

    I believe learning Find Fish would actually throw this off, and it might also interact weirdly with Find Treasure (but probably not, since Find Treasure would always be at least #3).

  6. That is awesome..gonna try it tonight. Thanks :)

  7. You could also install the WetSpot add-on which does the same thing, plus it can cycle through any combination of searches you may want.

    http://www.wowinterface.com/downloads/info14282-WetSpot.html

  8. Indeed, if the macro works (and given that several people have used it successfully I'll assume so), then it is nice and tidy!

    I've used several addons in the past to allow quick switching and they do the trick nicely.

    Since I don't farm any more (AH and a few dailies only for income), I don't have any of them installed atm, but there are several good options available at curse.com.

  9. "SetTracking(t) if t==1 then t=2 else t=1 end"

    or just write

    "SetTracking((t+3)/2) t=-t"

    ;)

  10. I just tried this last night. It works great....just as advertised.

  11. I just tried switching it up a little because of the find fish problem but i have had no success wondering if anyone has come up with a solution for this

Post a Comment

Insider Gold Strategies

Enter Your Name & Email Below to Receive My 7 Theories On Making Gold... Guaranteed to Put You Ahead of 99% of Players Out There

 

 

Recent Comments

Subscribe to recent comments

Labels

Blog Archive

Featured On:

Just My Two Copper - WoW Gold GuideJust My Two Copper - WoW Gold Guide