• 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 - Interpreting NULL value from MQ in Lua

tervalas

Active member
Having an issue with a loop.

X going from 1 to 500. mq.TLO.Me.Book(x) is reading correct data as long as there is a legitimate value and all other comparisons (including mq.TLO.Me.Book(x) ~= nil) using it in an if statement work. The moment it gets to the point where Me.Book[x] would return NULL in MQ, it is still passing that nil test and then throwing an error for trying to use it later in the conditional.

Should I be checking for something other than nil? I've tried mq.TLO.Me.Book(x) ~= "NULL" too and it still passes.
 
() are your friend. Always remember ().
Everything you want evaluated to a Lua primitive should end in ().
() with a value in them like Me.Book(1) do not count. This still needs to end in () or it will just be userdata.

/Lua parse mq.TLO.Me.Book(1)()

Also check out Lua expression evaluator

1707630720090.png
 
As aquietone said, doing it without the () is using it as userdata rather than a different data type that can be evaluated. Adding those should return strings that you can evaluate against.
 
() are your friend. Always remember ().
Everything you want evaluated to a lua primitive should end in ().
() with a value in them like Me.Book(1) do not count. This still needs to end in () or it will just be userdata.

/lua parse mq.TLO.Me.Book(1)()

Also check out lua expression evaluator

View attachment 57318
I think I found what my main confusion was. Not just the fact that I knew about this and had already started doing it last time I was working on what I'm working on and just completely forgot as I was working on a different portion. But that the part I'm working on seemed to be working fine other than this exact problem. Realized after this post that this was because when I was assigning this value to a global, and then using it later on for debugging, that string.format is okay with userdata as an input to %s while I figured that was showing it was already a string value.
 
I think I found what my main confusion was. Not just the fact that I knew about this and had already started doing it last time I was working on what I'm working on and just completely forgot as I was working on a different portion. But that the part I'm working on seemed to be working fine other than this exact problem. Realized after this post that this was because when I was assigning this value to a global, and then using it later on for debugging, that string.format is okay with userdata as an input to %s while I figured that was showing it was already a string value.
I know what you mean about using variables out of scope as I was running into the same problem on a different Lua I was writing. Glad you got it working.

Oh, and to help keep your code legible, you don't need string.format() to pass information using %s or %d, simply used printf() or mq.cmdf(). These handle the formatting for you, so that:

Autoformat
Lua:
-- Instead of having to use:
print('string.format('This is my %s', message))

-- You can use:
printf('This is my %s', message)
 
Oh, and to help keep your code legible, you don't need string.format() to pass information using %s or %d, simply used printf() or mq.cmdf(). These handle the formatting for you, so that:
I'm using the Write library functions (believe those are from Knightly but I may be wrong), and was just following from a different Lua for use. No biggy. This is more for me to see about making sure I'm understanding how to reinterpret macro code with Lua. I like tinkering, as I rarely have time to tackle a whole new thing.
 
Question - Interpreting NULL value from MQ in Lua

Users who are viewing this thread

Back
Top
Cart