• 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! 👋

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