• 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 - How to sequence commands...

Having some fun learning Lua, but ran into this issue. I am trying to make a button to camp my toons. I want everyone to set camp (using MQ2Boxr Camp command) and then set the main tank to tank mode (currently only supporting CWTN). Here is the code:
Code:
        mq.cmd('/squelch /dgga /boxr Camp')
        local command = string.format('/%s mode tank',mq.TLO.Group.MainTank.Class.ShortName())
        sendCommand(command,mq.TLO.Group.MainTank.Name())
This code is attached to an ImGui button press.

The issue I am having is that it seems that the Dannet command is coming in after the tank command, and is resetting the tank to assist mode. I tried inserting an 'mq.delay()' but that did nothing (literally, no matter what delay I use it does not delay - not sure mq.delay() works in the ImGui handler?).

I have had other cases of this happening, where Dannet commands occur in the opposite order from which they are sent (handled these using /multiline). But I would really like to know what is going on here. Alternatively, how would I wait for the Dannet command(s) to complete?
 
In ImGui there is no delay, but you can parcel off tasks to other routines that will delay.
I guess sorta helpful. How about we assume I am an idiot and would actually like to know how to do it?

I am not familiar with the threading model for Lua (if there is one), so not sure what parceling off a task would be. If the ImGui handler is running, and I want to do something like this, how?
 
I guess sorta helpful. How about we assume I am an idiot and would actually like to know how to do it?

I am not familiar with the threading model for Lua (if there is one), so not sure what parceling off a task would be. If the ImGui handler is running, and I want to do something like this, how?
Code:
require 'ImGui'
local lib = require ('actions')
local action = 0

if ImGui.Button("pressed") then
action = 1
end

-- at the bottom
while GUI do

if action  == 1 then
lib.actions()
action = 0
end

a separate file named

actions.Lua or whatever you want to call it

local actions = {}

-- code here

return actions

best to look here:


I am sure there are other ways to do it, but most of my code I always offload and make everything modular as possible.
 
Last edited:
Code:
require 'ImGui'
local actions = require ('actions')
local action = 0

if ImGui.Button("pressed") then
action = 1
end

-- at the bottom
while GUI do

if action  == 1 then
lib.actions()
action = 0
end

a separate file named

actions.lua or whatever you want to call it

local actions = {}

-- code here

return actions

best to look here:

Thanks. I was hoping it wouldn't come to that. But at the same time, not sure how it would be avoided.

So basically, view the app as a single thread with ImGui being an ISR. Defer any real processing from the ISR to the main thread through some sort of job queue. And here I thought my days of programming super-loops were behind me.

You mentioned an actions library. Does this implement some sort of job queue functionality? I am envisioning some sort of queue that would store a function and some set of parameters so that I could add generic jobs from the ImGui handler. Completely new to Lua, so while it will be interesting to learn how, I would also love to see an example. I will start looking through the Lua's on the site, but if you know of any that do this I'd appreciate a tip.

Edit: OK, have the job queue thing mostly sorted. Made a basic FIFO queue and can add tables to it where the first element is the function, and additional elements are arguments. I think this can be made to work. My next open question is data integrity. This queue will be shared between the main loop and the ImGui callback. In this case I may be able to make the queue safe if the main loop only pops and ImGui pushes. But is there a more general mechanism to prevent the ImGui handler from interrupting the main loop during a critical section? (I suppose I could just use a flag to prevent the ImGui handler from doing anything on its tick. The main loop can't interrupt the handler. Will have to look into it.).
 
Last edited:
Question - How to sequence commands...

Users who are viewing this thread

Back
Top
Cart