need help error attempt in table

tilemap = {{1,1,1,1,1},

          {1,0,0,0,0},

          {1,1,1,1,1},

          {1,0,0,0,0},

}

for i=1,5 do

for j=1,4 do

if tilemap[i][j]== 1 or nil then

         local tile = display.newImageRect( tiles,1,32,32)

         tile.x = 32*i-32+128

         tile.y = 32*j-16+128

         return nil

end

end

end

We need more details that this.  What is the exact error message and what line of code does it complain about exactly (mark it for us).

Also, FYI, you can and should format code posts for legibility.

formatyourcode.jpg

tilemap = {{1,1,1,1,1}, {1,0,0,0,0}, {1,1,1,1,1}, {1,0,0,0,0}, } for i=1,5 do for j=1,4 do if tilemap[i][j]== 1 or nil then local tile = display.newImageRect( tiles,1,32,32) tile.x = 32\*i-32+128 tile.y = 32\*j-16+128 return nil end end end

I think you really mean this:

for i=1,4 do for j=1,5 do

Oh, and as this is your first post.  Welcome to the community.  :slight_smile:

But I have to say, I’m not happy because now my mind is wandering while I need to work, thinking about what an 'owl on drugs 'looks like.

https://www.youtube.com/watch?v=05CXzjS8HX4

Ahahaahahahah

It’s doesn’t work…
Engine draw one box.

Ohhhh…I decided it problem.

Guys how to make the object move only when a key is pressed and not do movement when a key is not pressed?

I try to my with loop, the program crashes…

local mycircle = display.newCircle(32,display.contentHeight/2, 32 ) local function KeyEvent(event) if event.keyName=="up" then mycircle.y=mycircle.y - 8 end if (event.keyName=="down") then mycircle.y=mycircle.y + 8 end return false end Runtime:addEventListener( "key", KeyEvent ) print(mycircle.y)

1.  This question doesn’t seem related to the first.  Please always start a new thread when asking questions on new topics (and your game isn’t a topic :slight_smile: ).

  1. Use an enterFrame listener to move the object.

    local moveMagnitude = 8 local myCircle = display.newCircle(32,display.contentHeight/2, 32 ) myCircle.moveUp = 0 – finalize listener to remove key and enterFrame listeners when object is deleted function myCircle.finalize(self) Runtime:removeEventListener( “enterFrame”, self ) Runtime:removeEventListener( “key”, self ) end myCircle:addEventListener(“finalize”) – enterFrame - To move object function myCircle.enterFrame( self ) self.y = self.y + self.moveUp print( self.y ) end Runtime:addEventListener( “enterFrame”, myCircle ) – Key listener to adjust how much circle should move frame to frame function myCircle.key( self, event ) local key = event.keyName local phase = event.phase – UP ARROW KEY PRESS if( key = “up” and phase = “down” ) then self.moveUp = self.moveUp - moveMagnitude – UP ARROW KEY RELEASE elseif( key = “up” and phase = “up” ) then self.moveUp = self.moveUp + moveMagnitude – DOWN ARROW KEY PRESS if( key = “down” and phase = “down” ) then self.moveUp = self.moveUp + moveMagnitude – DOWN ARROW KEY RELEASE elseif( key = “down” and phase = “up” ) then self.moveUp = self.moveUp - moveMagnitude end return false end Runtime:addEventListener( “key”, myCircle )

We need more details that this.  What is the exact error message and what line of code does it complain about exactly (mark it for us).

Also, FYI, you can and should format code posts for legibility.

formatyourcode.jpg

tilemap = {{1,1,1,1,1}, {1,0,0,0,0}, {1,1,1,1,1}, {1,0,0,0,0}, } for i=1,5 do for j=1,4 do if tilemap[i][j]== 1 or nil then local tile = display.newImageRect( tiles,1,32,32) tile.x = 32\*i-32+128 tile.y = 32\*j-16+128 return nil end end end

I think you really mean this:

for i=1,4 do for j=1,5 do

Oh, and as this is your first post.  Welcome to the community.  :slight_smile:

But I have to say, I’m not happy because now my mind is wandering while I need to work, thinking about what an 'owl on drugs 'looks like.

https://www.youtube.com/watch?v=05CXzjS8HX4

Ahahaahahahah

It’s doesn’t work…
Engine draw one box.

Ohhhh…I decided it problem.

Guys how to make the object move only when a key is pressed and not do movement when a key is not pressed?

I try to my with loop, the program crashes…

local mycircle = display.newCircle(32,display.contentHeight/2, 32 ) local function KeyEvent(event) if event.keyName=="up" then mycircle.y=mycircle.y - 8 end if (event.keyName=="down") then mycircle.y=mycircle.y + 8 end return false end Runtime:addEventListener( "key", KeyEvent ) print(mycircle.y)

1.  This question doesn’t seem related to the first.  Please always start a new thread when asking questions on new topics (and your game isn’t a topic :slight_smile: ).

  1. Use an enterFrame listener to move the object.

    local moveMagnitude = 8 local myCircle = display.newCircle(32,display.contentHeight/2, 32 ) myCircle.moveUp = 0 – finalize listener to remove key and enterFrame listeners when object is deleted function myCircle.finalize(self) Runtime:removeEventListener( “enterFrame”, self ) Runtime:removeEventListener( “key”, self ) end myCircle:addEventListener(“finalize”) – enterFrame - To move object function myCircle.enterFrame( self ) self.y = self.y + self.moveUp print( self.y ) end Runtime:addEventListener( “enterFrame”, myCircle ) – Key listener to adjust how much circle should move frame to frame function myCircle.key( self, event ) local key = event.keyName local phase = event.phase – UP ARROW KEY PRESS if( key = “up” and phase = “down” ) then self.moveUp = self.moveUp - moveMagnitude – UP ARROW KEY RELEASE elseif( key = “up” and phase = “up” ) then self.moveUp = self.moveUp + moveMagnitude – DOWN ARROW KEY PRESS if( key = “down” and phase = “down” ) then self.moveUp = self.moveUp + moveMagnitude – DOWN ARROW KEY RELEASE elseif( key = “down” and phase = “up” ) then self.moveUp = self.moveUp - moveMagnitude end return false end Runtime:addEventListener( “key”, myCircle )