• 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

Lua - Lua Functions in parallel instead of in sequence?

When the code below is started, a() runs right away, then after 5 seconds b() runs, and then after 5 more seconds c() runs. And then it repeats.

time 1: a
time 5: b
time 10: c
time 15: a
time 20: b
etc.

What I want to happen is that a(), b(), and c() all start at the same time, and then each repeat every 5 seconds.
I simply want to delay the repetition of each function without making the other functions wait.

time 1: a,b,c
time 5: a,b,c
time 10: a,b,c
etc.

Is there a way to achieve this?

Lua:
local mq = require('mq')


local a = function()
    print('One')
    mq.delay(5000)
end

local b = function()
    print('Two')
    mq.delay(5000)
end

local c = function()
    print('Three')
    mq.delay(5000)
end

local terminate = false
while terminate == false do
    a()
    b()
    c()
end

In Macro, these would all start at the same time instead of waiting for each line to finish:
/timed 5s /docommand1
/timed 5s /docommand2
/timed 5s /docommand3
 
Last edited:
I am not 100% sure, but my way to view the processing of Lua is, that one Lua has one "processing-queue". If you want to run 3 different things contemporary you either need to implement multithreading or run 3 different Lua's.
Real multithreading may be above what you need. Can you achieve your goals by simply splitting the code in 3 different luas and start all 3 of them?
 
Well, not literally at the same time, but this would work:
Lua:
local mq = require('mq')

local a = function()
    print('One')
end

local b = function()
    print('Two')
end

local c = function()
    print('Three')
end

local terminate = false
while terminate == false do
    a()
    b()
    c()
    mq.delay(5000)
end

This works so long as the delay is the same. Can do the same thing with varying delays, but you would need to add some additional data structures.
 
Lua - Lua Functions in parallel instead of in sequence?

Users who are viewing this thread

Back
Top
Cart