1. #1

    Why does C_Timer.After() not delay my macro?

    Any Lua expert here who can tell my why this macro is instantly running through the list and does not delay each iteration by 10s?

    /run local a={0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2921,3,1,1,1,1,1,2601} function t(d,c,e) c=d[e]+c local n = GetItemInfo(c) UseItemByName(n) print(n) e=e+1 if e<=#d then C_Timer.After(10, t(d,c,e)) end end t(a,184630,1)
    Last edited by Puri; 2022-05-19 at 09:49 PM.

  2. #2
    Not a lua expert but my guess would be its broken to prevent botting somehow.

  3. #3
    You are not delaying the function call, you are immediately calling it. C_Timer.After wants a function object in the second argument but you're feeding it nil because that function call doesn't return anything. You should be getting a Lua error with a count of 27 on it.

    Correct:

    C_Timer.After(10, function(arg) dosomething=arg end)

    local myFunc = function(arg) dosomething=arg end
    C_Timer.After(10, myFunc)

    Incorrect:

    C_Timer.After(10, someFuncCall(randomArg) )



    Edit:

    I messed with it. First one still prints the item name if you want that. Second one doesn't. You also need to carry the function object through so that C_Timer can still use it. It would've worked originally because it was global, but it's bad practice to not localize very simple object names. Using /run or /script runs the following code in the same environment as the rest of the UI.

    /run local a,t={0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2921,3,1,1,1,1,1,2601},function(d,c,f,n) c=c+tremove(d,1) n=GetItemInfo(c) UseItemByName(n) print(n) if d[1] then C_Timer.After(10,function() f(d,c,f) end) end end t(a,184630,t)

    /run local a,t={0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2921,3,1,1,1,1,1,2601},function(d,c,f) c=c+tremove(d,1) UseItemByName((GetItemInfo(c))) if d[1] then C_Timer.After(10,function() f(d,c,f) end) end end t(a,184630,t)
    Last edited by Kanegasi; 2022-05-20 at 06:01 AM. Reason: added updated macros


    addons
    weakauras
    Lua Wall of Shame
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  4. #4
    Quote Originally Posted by Kanegasi View Post
    You are not delaying the function call, you are immediately calling it. C_Timer.After wants a function object in the second argument but you're feeding it nil because that function call doesn't return anything.
    Thank you very much for the explanation and your help!

  5. #5
    I got around to testing this and after seeing the item names, I thought this was great. After installing TLDRMissions, opening a bunch of those reagent boxes was getting tedious. I reorganized it a bit again to account for a nil error with Wowhead's recording addon, down to 3 second pause which seems to be long enough to loot the previous item, and to print "Opening" when it starts and "Done" when it's done. The all caps objects in print() are global string objects that contain a localized version of those words. Length is 253 characters and it takes 1 minute and 18 seconds to loop through them all.

    /run local f=function(t,i,r,n)i=i+tremove(t,1)n=GetItemInfo(i)if n then UseItemByName(n)end if t[1]then C_Timer.After(3,function()r(t,i,r)end)else print(DONE)end end print(OPENING)f({0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2921,3,1,1,1,1,1,2601},184630,f)
    Last edited by Kanegasi; 2022-05-20 at 05:00 PM. Reason: two prints


    addons
    weakauras
    Lua Wall of Shame
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

  6. #6
    I wouldnt have answered this question. it can lead to people hacking the game.
    TO FIX WOW:1. smaller server sizes & server-only LFG awarding satchels, so elite players help others. 2. "helper builds" with loom powers - talent trees so elite players cast buffs on low level players XP gain, HP/mana, regen, damage, etc. 3. "helper ilvl" scoring how much you help others. 4. observer games like in SC to watch/chat (like twitch but with MORE DETAILS & inside the wow UI) 5. guild leagues to compete with rival guilds for progression (with observer mode).6. jackpot world mobs.

  7. #7
    Uh, what? No it wouldn't. UseItemByName is usable by code out of combat. This macro is effectively a mini addon. There's no difference between using this macro and installing an addon named "Auto Open Mission Boxes". Lua isn't a hack. Be wary of scripts in general, but don't be scared of what you don't understand.


    addons
    weakauras
    Lua Wall of Shame
    Originally Posted by Zarhym (Blue Tracker)
    this thread is a waste of internet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •