• Hail, we're RedGuides. We want you to play six (yes, 6!) EverQuest characters at once. We have scripts and a friendly community to help, please join our playstyle and say hello! 👋
  • We've added LLM sections to our Terms & Rules and Resource Rules, for everyone's sanity & in-game safety.
    Read more
    a. Do not replace your voice with an LLM. This goes for your posts and your scripts. Drafting and editing with a tool is fine, but don't take you out of what you share.
    b. Do not replace your EQ character's voice with an LLM. We don't want scripts that speak over /ooc, /shout or other public channels. This has been an unwritten rule that's kept casino scripts off the site for decades, but we're now compelled to make it clear: keep automated communication private.

    Why Does RG Review Scripts?
    Nearly every LLM-written Lua script we see is making your character do impossible things, and rarely in a way that's beneficial to you. We've seen heavy server hammering, /target over impossible distances when /nav spawn would passively accomplish the same thing, a spawn search that fires 20+ times per second, and other pointless actions that are likely annoying GMs.

    You are welcome to use LLMs as a tool to structure, draft, and edit your work, but please read critically before hitting /lua run

Delay until condition

tweeb

Active member
I use this snippet *all the time* now so I thought I'd share.

`mq.delay` doesn't take a condition like regular `/delay`. So you can't write things like `/delay 3 ${Target.ID} == ${MyMobID}`

So I've been using this Lua function instead:
Lua:
function delay_until(predicate, timeout)
    local count = 0
    while not predicate() do
        mq.delay(1)
        if timeout and count > timeout then
            break
        end
        count = count + 1
    end
end
You pass in a function that takes no arguments, which will be evaluated repeatedly until it's true. This is easy in Lua since you can define functions in-line. Examples:

Lua:
    delay_until(function() return mq.TLO.Window('DynamicZoneWnd').Open() end, 5) -- wait for expedition window to be open with a short timeout
    delay_until(function() return mq.TLO.Spawn(npc_name).Distance3D() < 15 end) -- wait until we're near a specific NPC
Note that you can make the content of this function as complicated as you want (and you could give it a name, not just define it inline). This could be useful if you want something like "do a thing, retry until it succeeds"

Lua:
    my_complicated_function = function()
        --do
        --lots
        --of
        --stuff
        return result
    end
    delay_until(my_complicated_function)

One caveat about timeouts: it's not actually a *timer* so the amount of time that passes before a timeout might be a little unpredictable. It's not just delaying 1ms 5 times, it's 1ms 5 times + the overhead from 5 function calls + whatever's inside that function.
 
Delay until condition

Users who are viewing this thread

Back
Top
Cart