I'm creating an app with Corona structured in Class and I have a problem when I want pass an array objects for create an object. I have this:
main.lua
local SurpriseBoxClass = require("SurpriseBox")
local BoxClass = require("Box")
local box1 = BoxClass.new('palo', 'images/chestClose.gif', 'OPEN')
local box2 = BoxClass.new('moneda', 'images/chestClose.gif', 'OPEN')
boxes = { box1, box2 }
local game = SurpriseBoxClass.new(boxes)
SurpriseBox.lua
local SurpriseBox = {}
local SurpriseBox_mt = { __index = SurpriseBox }
function SurpriseBox.new(boxesAux)
local object = {
boxes = boxesAux
}
return setmetatable( object, SurpriseBox_mt )
end
The problem is when I want to print the content of array in a method of SurpriseBox, and the program said me that the array is nil if for example I do this:
print(boxes[0])
What can I do?
Thanks!