• 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 - Coding Question: mq.TLO.Me.Class.ShortName

Don't beat me up too badly please. Hacking my way through this stuff with no programming background. I'm not sure if there's an easy solution to this and my search skills are lacking or....

In macroscript you could write: /if (${Me.Class.ShortName.Equal[CLR,SHM,DRU]}) /dostuff

I'm struggling to figure out similar syntax in Lua.

The only options I've found through searching is creating an "am I a priest" function and calling the function when needed, or adding priest shortnames to a table and iterating through it. Is there an easier way to compare to one or more strings without a lengthy or list, a function, or iterating through a table?
 
Don't beat me up too badly please. Hacking my way through this stuff with no programming background. I'm not sure if there's an easy solution to this and my search skills are lacking or....

In macroscript you could write: /if (${Me.Class.ShortName.Equal[CLR,SHM,DRU]}) /dostuff

I'm struggling to figure out similar syntax in lua.

The only options I've found through searching is creating an "am I a priest" function and calling the function when needed, or adding priest shortnames to a table and iterating through it. Is there an easier way to compare to one or more strings without a lengthy or list, a function, or iterating through a table?
here's a snippet:
local my_class = mq.TLO.Me.Class.ShortName()

here's another:
mq.TLO.Me.Class.ShortName() ~= 'MAG' then

I got both of these from a text file search for "ShortName". In a text editor (I think Word has this function also), do a "Find in Files", using the "search subdirectories" option, pointing the search at your version of the MacroQuest\Lua folder.

There is gold in them thar hills.
 
You can use string.find(haystack, needle) to see if your text exists within another text.

For example:
string.find
Lua:
_CasterClasses = 'DRU,CLR,SHM,MAG,WIZ,NEC,ENC'

if string.find(_CasterClasses, mq.TLO.Me.Class.ShortName()) then
  mq.cmd("/echo match")
else
  mq.cmd("/echo no match")
end

string.find will return nil if the value is not found. It will return the position of the value if it is found.
nil resolves as False. The first position is 1, which resolves to true.

Alternatively, for your specific use case, you can use:

HealerType
Code:
mq.TLO.Me.Class.HealerType()

This returns a boolean
1720185918568.png
 
You can use string.find(haystack, needle) to see if your text exists within another text.

For example:
string.find
Lua:
_CasterClasses = 'DRU,CLR,SHM,MAG,WIZ,NEC,ENC'

if string.find(_CasterClasses, mq.TLO.Me.Class.ShortName()) then
  mq.cmd("/echo match")
else
  mq.cmd("/echo no match")
end

string.find will return nil if the value is not found. It will return the position of the value if it is found.
nil resolves as False. The first position is 1, which resolves to true.

Alternatively, for your specific use case, you can use:

HealerType
Code:
mq.TLO.Me.Class.HealerType()

This returns a boolean
View attachment 63022
That's perfect, thank you!
 
Is there a cleaner way to do this than iterating through the table with a for loop?
Lua:
local healers = {CLR = true, DRU = true, SHM = true}
if healers[mq.TLO.Me.Class.ShortName()]  ~= nil then
--- we matched
end
no loop needed. which is why Brainiac said use key's as the names its an easy match.
 
Lua:
local healers = {CLR = true, DRU = true, SHM = true}
if healers[mq.TLO.Me.Class.ShortName()]  ~= nil then
--- we matched
end
no loop needed. which is why Brainiac said use key's as the names its an easy match.
Awesome! I couldn’t wrap my head around the syntax. Thank you! Now I’m following.
 
Question - Coding Question: mq.TLO.Me.Class.ShortName

Users who are viewing this thread

Back
Top
Cart