• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver

Question - Spawns in Array

Joined
Jan 29, 2021
RedCents
193¢
Is it possible to pass an array of Spawn objects to a function? I haven't found the right combination yet. Maybe I can only add the Spawn IDs to an array and pass that

Something like
targets = {mq.TLO.Spawn("Bert"),mq.TLO.Spawn("Ernie")}
or
targets = {mq.TLO.Spawn("Bert")(),mq.TLO.Spawn("Ernie")()}

list_targets(targets)

function list_targets(players)
for i=0, #players do
print(' - ' .. players.Name())
end
end
 
Arrays are tables in Lua.
So what you want to do is use the table insert function.

There's lots of ways you could do this, here's an untested idea.

Lua:
local targets = {}
table.insert(targets, mq.TLO.Spawn("Bert")())
table.insert(targets, mq.TLO.Spawn("Ernie"())
list_targets(targets)
 
Will give it a try. This works w/o using the table method, but not sure why

Code:
targets = {}
for i = 0, mq.TLO.Group.Members() do
    targets[i] = mq.TLO.Group.Member(i)
end
list_targets(targets)
 
Will give it a try. This works w/o using the table method, but not sure why

Code:
targets = {}
for i = 0, mq.TLO.Group.Members() do
    targets[i] = mq.TLO.Group.Member(i)
end
list_targets(targets)
This is still using a table. targets = {} is a table in both our examples. In your code, you're directly accessing and setting the value to the table. Both work and both are completely valid. Nice work.
 
Question - Spawns in Array

Users who are viewing this thread

Back
Top
Cart