Page 1 of 1

Expected ImageData got nil

Posted: Thu Dec 22, 2016 9:01 am
by ExpressDawn
Hello forums!
I've been using Love2d for a little bit in order to create a prototype for a game. I'm trying to make a sprite loader, mostly based on the code on Build and Gun here: http://www.buildandgun.com/2014/07/anim ... ove2d.html

I've had to play around with my code and have probably messed up syntax somewhere, but the issue at the moment is that I keep getting an error about love.graphics.newImage expecting ImageData and receiving nil (it's receiving nil because I'm only trying to define the function, not use it at the moment).
I'll attach the Game file and the sprite loading file, maybe someone could help me out?

Thanks in advance, and I'm sorry if this has been asked about already. I've searched and come up empty, but I could've missed something.

Re: Expected ImageData got nil

Posted: Thu Dec 22, 2016 10:29 am
by raidho36
Reading the whole error message often helps, as it shows exact location where the error occurred. I assume it's in main file at line 74 where you use undefined (and therefore being a global, nil) variable.

Re: Expected ImageData got nil

Posted: Thu Dec 22, 2016 11:11 am
by ExpressDawn
It's actually an error in sp on line 10-
bad argument #1 to newImage (imageData expected got nil)
Goes on to say:

Code: Select all

Traceback

gamestate.lua:89: in function <gamestate.lua:88>
[C]: in function 'newImage'
sp/lua:10: in function 'spriteLoad'
sp.lua:33: in function 'updateFace'
sp.lua:43: in function 'update'
gamestate.lua:88: in function 'update'
[C]: in function 'xpcall'

Re: Expected ImageData got nil

Posted: Thu Dec 22, 2016 12:23 pm
by raidho36
Right, I didn't pay much attention; the are a bunch of globals in your code that you use in various functions, one functions messing it up for others may be the cause of the issue.

Re: Expected ImageData got nil

Posted: Thu Dec 22, 2016 12:37 pm
by ExpressDawn
Ahh, alright
I'll work that out, then
Thanks!