• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - Understanding delay with conditions

Joined
Sep 27, 2020
RedCents
6,554¢
I've got a script (see attached) that I'm attempting to use to make sure I have a good understanding of how I should be using a delay with a condition triggered by an event. Call it a sanity check. As a setup, I have a Cleric character in the tutorial running NextCleric casting Yaulp every time it drops. The issue I'm seeing is the script is stopping as if the condition is met, but the output clearly indicates it isn't met. Where am I going wrong in my thought process here?

eventtest_output.png
yaulp_casting.png
 

Attachments

Assumption is you want the script to break and end when you cast. Removing the mq.delay call inside the delay callback broke out and ended the script as I started casting a spell.

Lua:
local mq = require('mq')

local stop = false

local print_ts = function(msg)
    print('\aw['..mq.TLO.Time()..'] '..msg)
end

local BeginCast = function ()
    print_ts('casting started')
    stop = true
end

mq.event('BeginCasting', "#*#You begin casting#*#", BeginCast)

print_ts('start script')
print_ts(string.format('stop: %s', stop))

local function delay_callback()
    mq.doevents()
    -- mq.delay(50)
    print_ts(string.format('stop (in delay): %s', stop))
    return stop
end

mq.delay(30000, delay_callback)

print_ts(string.format('stop: %s', stop))
print_ts('end script')
 
I'll start with that my initial script didn't have a delay included. That was added to stop zerging the CPU. But without the delay, it still didn't work. You've also moved the code to a declared function rather than an anonymous one. This could be the ultimate culprit, but not one I'm willing to give up.
 
Alright. I'm not sure what I did wrong in the first place (i.e., I distinctly remember putting the delay in there after things didn't work as expected), but yes. Removing the mq.delay gives me the expected behavior. That said, I think I'll keep the Delay library for my own usage. It affords me two benefits. 1) calls mq.doevents on each pulse, and 2) I can control the pulse delay. Is it perfect? Nope. But I don't need perfect.

Thanks for clearing it up for me.
 
Question - Understanding delay with conditions

Users who are viewing this thread

Back
Top
Cart