local lamps = {} -- (table of lamps, and states)массив состояний ламп lamps[1] = { lamp = display.newCircle(160,50,35), state = 0 } lamps[2] = { lamp = display.newCircle(60,50,35), state = 0 } lamps[3] = { lamp = display.newCircle(260,50,35), state = 0 } lamps[4] = { lamp = display.newCircle(160,150,35), state = 0 } lamps[5] = { lamp = display.newCircle(60,150,35), state = 0 } lamps[6] = { lamp = display.newCircle(260,150,35); state = 0 } local function lamp\_tap (event) if event.target.state == 1 then -- if we choose correct lamp event.target.lamp:setFillColor(0,0.8,0) else -- if not event.target.lamp:setFillColor(0.8,0,0) end end for i=1,6 do lamps[i].lamp:addEventListener("tap",lamp\_tap) end
I’m using this “system” of index in other functions, and they’re working, but in lamp_tap something goes wrong,and I see an error : “attempt to index field ‘lamp’(a nil value)”. What’s wrong?
P.S sorry for my english