Imagetable always nil, not working as expected

Started few weeks ago learning lua and I'd like to continue working on my small project, so bear with me but I don't have a lot of notions in 2D design/graphics.

I've started taking a look to the Example project Level 1-1 where in player.lua it creates an imagetable with self.playerImages ='img/player').
What is driving me crazy is that if I change only ONE pixel in that png it stops working. Imagetable is nil. If I upload a new image doesn't work too.

But today I used that same code in another new project I created, and even if I'm using player-table-16-32.png, imagetable is nil. Same code, just different project.

What notion I'm missing here? Any doc reference? Do I need to set up the tables images I upload in a new project in some way?

Probably it's something really basic as I couldn't find any doc or issues regarding this, but please any kind of clarification are welcome as I'm really close to quit :frowning:

Thanks! :pray:

It sounds like the build process isn’t picking up the image for whatever reason. Does the output from pdc mention anything to do with the image? (If you’re using Nova you can find that in the Reports sidebar.)

Does the resulting .pdx contain the processed image as a .pdt file? In the level 1-1 example it should be located at Level 1-1.pdx/img/player.pdt.

Also, what image editor were you using when you tried editing the image? Maybe it’s saving incompatible pngs for some reason.

Hi Dale,
I'm not using Nova but IntelliJ, with an extension for Lua - so not sure about pdc output.

.pdx contains the processed images, even the image file I used in the imagetable that failed.

To edit files I use ProCreate for iPads.

The weird thing is the problem exists only for images I use in imagetable. Any other files, even the one I created with ProCreate, work correctly if I use them in"...").

Just making sure I understand, you’re able to build and run Level 1-1 with the original version of the image and it works?

I just tested and I was able to:

  1. import player-table-16-32.png into Procreate
  2. Draw over the image
  3. Share from Procreate as PNG and send the file back to my computer
  4. Replace Source/img/player-table-16-32.png with my edited version
  5. Build and run again from my IDE, and my edited version appeared in the game.

Are you sure the png has the same dimensions after you edit it (112x32)? The only special requirement for image tables that I’m aware of is that the total dimensions should be a multiple of the frame dimensions in the filename (e.g. 112 is a multiple of 16)

Yes, same size just few pixels different, same png extension but it fails.

It is even weirder that if I use that same code in a different new project it doesn't work with the same nil issue, even using the original png image.

Can you post some of your code? You may have an other problem that causes the nil value.

local pd <const> = playdate
local gfx <const> =


function Player:init()

    self.image ='images/player')
    self:moveTo(330, 120)

And then I call


in main.lua outside any function.

However, if I use"images/hellothere") it works showing the entire image.
The error message is: attempt to index a nil value (global 'image')

Does it work if you replace image:getImage(1) by self.image:getImage(1) ?


Tried but no, doesn't work. image or self.image are both undefined.

When I copy and paste your Player:init code, I get the same error: attempt to index a nil value (global 'image').

When I change self:setImage(image:getImage(1)) to self:setImage(self.image:getImage(1)), I do not get the error.

1 Like