android - pass an array objects in Corona with class -


i'm creating app corona structured in class , have problem when want pass array objects create object. 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 when want print content of array in method of surprisebox, , program said me array nil if example this:

print(boxes[0]) 

what can do?

thanks!

lua tables 1-based.

try print(boxes[1], boxes[2]).

it print table id. if need print contents of table, must iterate on fields, or use custom printer you (see "print table recursively").


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -