'self' (a nil value)

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
Saint'N Studios
Prole
Posts: 2
Joined: Sun Jun 19, 2016 11:47 am

'self' (a nil value)

Post by Saint'N Studios »

I'm using Goature's tutorial for the base of my game and it keeps on saying enttities/box.lua:23: attempt to index 'self' (a nil value).
I don't know how to fix it can i plz have help.
Attachments
entities.lua
(923 Bytes) Downloaded 112 times
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: 'self' (a nil value)

Post by Nixola »

Please follow the guidelines. Make a .love file containing all of your code and assets and upload it, or we may not be able to help.
In this case, you probably used "." instrad of ":" when calling a function or vice versa.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
DanielPower
Citizen
Posts: 50
Joined: Wed Apr 29, 2015 5:28 pm

Re: 'self' (a nil value)

Post by DanielPower »

I'm assuming your issue lies either here:

Code: Select all

if ent.update then 
	ent:update(dt)
end
or here:

Code: Select all

if ent.draw then 
	ent.draw()
end
You're mixing up '.' and ':' on the ent.update call. But without the .love file, I can't help any more than that.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: 'self' (a nil value)

Post by zorg »

DanielPower wrote:You're mixing up '.' and ':' on the ent.update call. But without the .love file, I can't help any more than that.
Technically, he's not, since he's checking if the field exists or not, and even if it's a function that would require a self parameter to be passed first (that : would pass implicitly when called),

Code: Select all

if table:field then
is, to my knowledge, not allowed code.

That said, the error might be that he's mixing up the . and or : when one of the calls actually happen. (either update should be with a ".", or draw with a ":")
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Saint'N Studios
Prole
Posts: 2
Joined: Sun Jun 19, 2016 11:47 am

Re: 'self' (a nil value)

Post by Saint'N Studios »

I posted the wrong file here's the right one.
Attachments
Unidentified .love
(274.21 KiB) Downloaded 103 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 6 guests