• 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 - Concatenating mq.TLO string data?

Hey, though I've programmed before, I'm super new to MQ and Lua. I'm trying to setup some mq.events depending on some variables, using mq.TLO.Target.Name to be precise. When I try to concatenate it with any string at all, like print(mq.TLO.Target.Name .. ' test'), the script crashes. I've been reading Lua documentations a bit, but I'm stumped here. I'm sure it's a simple problem/solution, but I'd appreciate someone pointing a newbie in the right direction.
 
Solution
there are several ways to concat with lua > here is the lua concat page <

you can do

Lua:
print('thing' .. var) - this would concat the value of "var" on the end of thing
you could also just do
Lua:
print('thing' .. 'stuff') -- this would concat "stuff" onto "thing" resulting in thingstuff

here is me running that in mq using the /lua parse functionality
Lua:
> /lua parse print('thing' .. 'stuff')
thingstuff

what you would likely be wanting to do is something like

Lua:
-- this is bringing in MQ "stuff"
local mq = require 'mq'

-- we are evaluating and assigning the information from our target's name to a variable named "targetname" - care to notice the "()" on the end of it, this means we want the data from it, not the...
there are several ways to concat with Lua > here is the lua concat page <

you can do

Lua:
print('thing' .. var) - this would concat the value of "var" on the end of thing
you could also just do
Lua:
print('thing' .. 'stuff') -- this would concat "stuff" onto "thing" resulting in thingstuff

here is me running that in mq using the /Lua parse functionality
Lua:
> /lua parse print('thing' .. 'stuff')
thingstuff

what you would likely be wanting to do is something like

Lua:
-- this is bringing in MQ "stuff"
local mq = require 'mq'

-- we are evaluating and assigning the information from our target's name to a variable named "targetname" - care to notice the "()" on the end of it, this means we want the data from it, not the actual datatype
local targetname = mq.TLO.Target.Name()

local function main()
    -- this is printing the aforcreated targetname and putting ' is gonna die' on the end of it
    -- if we were targeting RedBot (sorry red) it would print "RedBot is gonna die"
    print(targetname .. ' is gonna die')
end

-- this has the lua script run the function we created above
main()

here's another quick and dirty example of different ways to do something like that
Lua:
local mq = require 'mq'

local function main()
    local targetname = mq.TLO.Target.Name()
    local myname = mq.TLO.Me.Name()
    print(string.format("%s %s %s %s", "My Name: ", myname, " Target is: ", targetname))
end

main()

I had the note in the commends of the above Lua, but hytiek skipped over it later so i edited this to include "-- we are evaluating and assigning the information from our target's name to a variable named "targetname" - care to notice the "()" on the end of it, this means we want the data from it, not the actual datatype"

your snippet is missing the "()" on the end
 
Last edited:
Solution
there are several ways to concat with lua > here is the lua concat page <

you can do

Lua:
print('thing' .. var) - this would concat the value of "var" on the end of thing
you could also just do
Lua:
print('thing' .. 'stuff') -- this would concat "stuff" onto "thing" resulting in thingstuff

here is me running that in mq using the /lua parse functionality
Lua:
> /lua parse print('thing' .. 'stuff')
thingstuff

what you would likely be wanting to do is something like

Lua:
-- this is bringing in MQ "stuff"
local mq = require 'mq'

-- we are evaluating and assigning the information from our target's name to a variable named "targetname" - care to notice the "()" on the end of it, this means we want the data from it, not the actual datatype
local targetname = mq.TLO.Target.Name()

local function main()
    -- this is printing the aforcreated targetname and putting ' is gonna die' on the end of it
    -- if we were targeting RedBot (sorry red) it would print "RedBot is gonna die"
    print(targetname .. ' is gonna die')
end

-- this has the lua script run the function we created above
main()
Thanks for the swift reply! So, turns out the problem was with the way I was calling mq.TLO.Target.Name as I assumed it was a property, when I should have used () at the end like calling a function. Or is it still a property and that's just Lua syntax?
 
Thanks for the swift reply! So, turns out the problem was with the way I was calling mq.TLO.Target.Name as I assumed it was a property, when I should have used () at the end like calling a function. Or is it still a property and that's just Lua syntax?
good rule of thumb is "always use () if you want the information from the thing"

example:

in my guildclicky i use

Lua:
local ground = mq.TLO.Ground

this allows me later to do things like ground.Search (without typing the mq.TLO.Ground)

Lua:
local function validateportal(item)
    return ground.Search(item)() ~= nil
end
 
To address precisely what you shared:

print(mq.TLO.Target.Name .. ' test')

needs to be:

print(mq.TLO.Target.Name() .. ' test')

I recommend rather using:

print(mq.TLO.Target.CleanName() .. ' test')

Now when you get further and find an error about being unable to concatenate a Boolean:

print('printing my Boolean: '.. tostring(bVar1))
 
Question - Concatenating mq.TLO string data?

Users who are viewing this thread

Back
Top
Cart