• 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 - LUA Help #1

Mythas

Well-known member
Hey all,

I'm trying to troubleshoot this little Lua helper I'm trying to write and need a set of fresh eyes to double-check me, if anyone would be so kind:

Code:
local mq = require('mq')

local XClear = function() --naming the function to be called later.
    for i = 1, mq.TLO.Me.XTargetSlots() do --finding how many loops to iterate through
        if mq.TLO.Me.XTarget(i)() ~= nil then --if something is on xtarget, clears it.
            mq.cmdf('/xtar set %d autohater', i) --passes value of i into the command "/xtar set # autohater"
            mq.delay(10) -- waits 1s
            if mq.TLO.Me.XTarget(i)() == nil then break end --this should break out of the loop and wait 10 more seconds?
        end
    end
end   

while true do --while true... what would cause this to be false?
    mq.delay(100) -- delays 10s then...
    XClear() -- ...calls XClear function
end
 
Code:
-- change this 
local XClear = function() 
  -- body
end

-- to this
local function xclear()
  -- body
end

-- mq.delay(10) is 10ms, use mq.delay(1000) or mq.delay('1s')
-- mq.delay(100) is 100ms, use mq.delay('10s')

Other than that, what are the issues?
 
It was ending immediately, but I think I had a mistake in the section if mq.TLO.Me.XTarget(i)() == nil then break end . I'm just below novice in this language so thank you for checking for me.
 
Question - LUA Help #1

Users who are viewing this thread

Back
Top
Cart