• 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 - Noob questions for a lua script

Joined
Jul 24, 2019
RedCents
24,072¢
Hi all,
I am trying to convert a macro for buffing the raid into a much smarter Lua, but simple syntax things are smashing me.

Here is the Psuedo Psuedo Code for what I am trying to do:
  • Determine the Number of Raiders in the raid.
  • Create a 2 Dimensional Array equal in size to the number of raiders
  • Initialise all elements of the array to 0
  • Fill the array with the name, class
In the Lua Expression Builder i know
${Raid.Members} evaluates to 54
${Raid.Member[1].Class} = Shadow Knight
${Raid.Member[1].Name} = BOB (Not really..but it does Equate to my raid leaders name.)

The code is below:

The issues are:

1. As expected... my variable raiders is 54
but when i attempt to do a for loop: for i=1, raiders do it gives a for limit must be a number

ok..weird but moving on.....
I change the for to a hard coded 54 and move on....
It creates the Table within a Table for a 2 dimensional array

Next..im trying to populate the array with data from the raid Name and Class - but the mq.TLO.Raid.Member[toon_number].Name and mq.TLO.Raid.Member[toon_number].Class) now evaluates as NULL


[CODE title="test.Lua"]local mq = require 'mq'

raiders = mq.TLO.Raid.Members

mq.cmd('/echo The Raid Total Members: ', raiders )


myRaid ={}
for i=1, raiders do
myRaid = {} -- create a new row
for j=1,2 do
myRaid[j] = 0
mq.cmd('/echo Init: ',i, j, myRaid[j])
end
end

toon_number = 1
while toon_number <= raiders do

mq.cmd('/echo Toon_Number:', toon_number)

mq.cmd('/echo Toon_Number:', mq.TLO.Raid.Member[toon_number].Name)
mq.cmd('/echo Toon_Number:', mq.TLO.Raid.Member[toon_number].Class)

-- myRaid[toon_number][1] = mq.TLO.Raid.Member[toon_number].Name
-- myRaid[toon_number][2] = mq.TLO.Raid.Member[toon_number].Class
-- mq.cmd('/echo Adding toon:', myRaid[toon_Number][1], myRaid[toon_number][2])
toon_number = toon_number + 1
end[/CODE]

Any assistance greatly appreciated.
 
Hi all,
I am trying to convert a macro for buffing the raid into a much smarter lua, but simple syntax things are smashing me.

Here is the Psuedo Psuedo Code for what I am trying to do:
  • Determine the Number of Raiders in the raid.
  • Create a 2 Dimensional Array equal in size to the number of raiders
  • Initialise all elements of the array to 0
  • Fill the array with the name, class
In the Lua Expression Builder i know
${Raid.Members} evaluates to 54
${Raid.Member[1].Class} = Shadow Knight
${Raid.Member[1].Name} = BOB (Not really..but it does Equate to my raid leaders name.)

The code is below:

The issues are:

1. As expected... my variable raiders is 54
but when i attempt to do a for loop: for i=1, raiders do it gives a for limit must be a number

ok..weird but moving on.....
I change the for to a hard coded 54 and move on....
It creates the Table within a Table for a 2 dimensional array

Next..im trying to populate the array with data from the raid Name and Class - but the mq.TLO.Raid.Member[toon_number].Name and mq.TLO.Raid.Member[toon_number].Class) now evaluates as NULL


[CODE title="test.lua"]local mq = require 'mq'

raiders = mq.TLO.Raid.Members

mq.cmd('/echo The Raid Total Members: ', raiders )


myRaid ={}
for i=1, raiders do
myRaid = {} -- create a new row
for j=1,2 do
myRaid[j] = 0
mq.cmd('/echo Init: ',i, j, myRaid[j])
end
end

toon_number = 1
while toon_number <= raiders do

mq.cmd('/echo Toon_Number:', toon_number)

mq.cmd('/echo Toon_Number:', mq.TLO.Raid.Member[toon_number].Name)
mq.cmd('/echo Toon_Number:', mq.TLO.Raid.Member[toon_number].Class)

-- myRaid[toon_number][1] = mq.TLO.Raid.Member[toon_number].Name
-- myRaid[toon_number][2] = mq.TLO.Raid.Member[toon_number].Class
-- mq.cmd('/echo Adding toon:', myRaid[toon_Number][1], myRaid[toon_number][2])
toon_number = toon_number + 1
end[/CODE]

Any assistance greatly appreciated.

Something like this?
Code:
local mq = require 'mq'

local raiders = mq.TLO.Raid.Members

mq.cmd('/echo The Raid Total Members: ',  raiders )


local myRaid ={}
for i=1, raiders() do
  myRaid[i] = {}     -- create a new row
  for j=1,2 do
    myRaid[i][j] = 0
    mq.cmd('/echo Init: ',i, j, myRaid[i][j])
  end
end

local toon_number = 1
while toon_number <= raiders() do

mq.cmd('/echo Toon_Number:', toon_number)

mq.cmd('/echo Toon_Number:', mq.TLO.Raid.Member[toon_number].Name)
mq.cmd('/echo Toon_Number:', mq.TLO.Raid.Member[toon_number].Class)

--    myRaid[toon_number][1] = mq.TLO.Raid.Member[toon_number].Name
--    myRaid[toon_number][2] = mq.TLO.Raid.Member[toon_number].Class
--   mq.cmd('/echo Adding toon:', myRaid[toon_Number][1], myRaid[toon_number][2])
    toon_number = toon_number + 1
end
 
Yep...that solved the first part.. so If I am accessing a TLO like mq.TLO.Raid.Members i need () on the end of the variable?

do I need to do something similar for mq.TLO.Raid.Member[1].Name
 
Yep...that solved the first part.. so If I am accessing a TLO like mq.TLO.Raid.Members i need () on the end of the variable?

do I need to do something similar for mq.TLO.Raid.Member[1].Name
Code:
local mq = require 'mq'

local raiders = mq.TLO.Raid.Members

mq.cmd('/echo The Raid Total Members: ',  raiders )


local myRaid ={}
for i=1, raiders() do
  myRaid[i] = {}     -- create a new row
  for j=1,2 do
    myRaid[i][j] = 0
    mq.cmd('/echo Init: ',i, j, myRaid[i][j])
  end
end

local toon_number = 1

while toon_number <= raiders() do
local Toon_Name = mq.TLO.Raid.Member(toon_number).Name()
local Toon_Class = mq.TLO.Raid.Member(toon_number).Class()
mq.cmd('/echo Toon_Number:', toon_number)
mq.cmd('/echo Toon_Name: ', Toon_Name)
mq.cmd('/echo Toon_Class: ', Toon_Class)

myRaid[toon_number][1] = mq.TLO.Raid.Member[toon_number].Name
myRaid[toon_number][2] = mq.TLO.Raid.Member[toon_number].Class
--mq.cmd('/echo Adding toon:', myRaid[toon_number][1], myRaid[toon_number][2])
    toon_number = toon_number + 1
end
 
Awesome Sauce - Thanks Cannonball...Ill see if I can get the rest of the macro working and post it here. Its all easy once you have the Syntax right.
 
Question - Noob questions for a lua script

Users who are viewing this thread

Back
Top
Cart