• 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

Question - Return value of an event

Addict

Well-known member
I would like to capture the return value of an event.

Here is a toy example of what I am after:

Lua
Lua:
local mq = require("mq")

local eventSay = function (line, arg1, arg2)
    print(arg1)
    print(arg2)
    return true
end

mq.event("eventSay", "#1# says, #2#", eventSay)

local function test()
    local result
    while true do
        result = mq.doevents("eventSay")
        print(result)
        mq.delay(5000)
    end
end

test()

I would like result to print true (return value of eventSay) when the event is triggered from the queue. I am able to do something similar in macroscript but I am unsure how to do it in Lua. I *think* I could do it with global variables but I would really like to avoid that if possible.

Just to clarify this is what I mean by globals:

Lua
Lua:
local mq = require("mq")

local result

local eventSay = function (line, arg1, arg2)
    print(arg1)
    print(arg2)
    result = true
end

mq.event('eventSay', "#1# says, #2#", eventSay)

local function test()
    while true do
        mq.doevents("eventSay")
        print(result)
        mq.delay(5000)
    end
end

test()

The code above works as expected (result is nil until someone says something and then result is true). I just don't think managing these global flags is the best way but I may of course be wrong.

Any tips and/or tricks?
 
Last edited:
As was stated by brainiac in discord, the second method of having a global that is available for the event and handler is the way to go.
 
Question - Return value of an event

Users who are viewing this thread

Back
Top
Cart