I am trying to put a table from one class into another class. It seems like it would be pretty straight forward but I keep getting an error, but only after it runs it’s function using the table. I just ask it print the table[i] which it does but then it says it gets nil.
Here is the simple code for this test.
Thanks in advance for any help.
--# Main
-- table into class test
-- Use this function to perform your initial setup
function setup()
nTab = NewTable()
useT = UseTable()
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(5)
end
--# NewTable
NewTable = class()
function NewTable:init()
-- you can accept and set parameters here
nt = {1,2,3,4,5}
UseTable(nt)
end
--# UseTable
UseTable = class()
function UseTable:init(tb)
-- you can accept and set parameters here
for i,v in ipairs(tb) do
print(tb[i])
end
end