Expected ImageData got nil

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
ExpressDawn
Prole
Posts: 3
Joined: Thu Dec 22, 2016 8:50 am

Expected ImageData got nil

Post 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.
Attachments
sp.lua
The loader
(1.15 KiB) Downloaded 120 times
game.lua
Where I'm calling the functions, is a game state
(2.26 KiB) Downloaded 102 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Expected ImageData got nil

Post 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.
ExpressDawn
Prole
Posts: 3
Joined: Thu Dec 22, 2016 8:50 am

Re: Expected ImageData got nil

Post 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'
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Expected ImageData got nil

Post 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.
ExpressDawn
Prole
Posts: 3
Joined: Thu Dec 22, 2016 8:50 am

Re: Expected ImageData got nil

Post by ExpressDawn »

Ahh, alright
I'll work that out, then
Thanks!
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests