[FIXED] Yet Again: Fails to index field "?"

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
B-Man99
Prole
Posts: 36
Joined: Wed Jul 25, 2012 10:51 pm
Location: Right behind you. I know you looked. Heck, even I looked

[FIXED] Yet Again: Fails to index field "?"

Post by B-Man99 »

I started a new project yesterday, this one I'm hoping to make into a full-feature game, unlike quick things I've been working on in the past year to get me used to Love2d, etc. I've isolated the loadLevel function, because if I remove the line in love.load() that calls loadLevel(), the game starts without any errors. Most bugs I am able to think about a little (or a lot) and fix, but this particular error is harder for me. Love2d fails to index a nil field, but I cannot seem to figure out what that field is. Can anyone please explain how to fix this error, or give me any advice? Thank you, it would really help!
Attachments
Reactors.love
(7 KiB) Downloaded 106 times
Last edited by B-Man99 on Fri Feb 22, 2013 3:26 am, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Yet Again: Fails to index field "?"

Post by bartbes »

Well, thankfully the error gives us a location, main.lua:157, so I look at that and see 3 table index operations that could cause this, namely grid[x], grid[x][y] and leveldata. So, I added the following code (before 157):

Code: Select all

print(grid[x])
print(grid[x][y])
print(leveldata[i])
That showed me the error was in the second of the two lines, and the result of the print indeed showed grid[x] is nil.
B-Man99
Prole
Posts: 36
Joined: Wed Jul 25, 2012 10:51 pm
Location: Right behind you. I know you looked. Heck, even I looked

Re: Yet Again: Fails to index field "?"

Post by B-Man99 »

bartbes wrote:Well, thankfully the error gives us a location, main.lua:157, so I look at that and see 3 table index operations that could cause this, namely grid[x], grid[x][y] and leveldata. So, I added the following code (before 157):

Code: Select all

print(grid[x])
print(grid[x][y])
print(leveldata[i])
That showed me the error was in the second of the two lines, and the result of the print indeed showed grid[x] is nil.
Thanks, I would have done that except that my console opens up but doesn't print anything. I saw a similar problem on these forums but with no solution. Thank you for helping. Now I just need to figure out why grid[x] is nil. I'll update this post if I figure out why, but I could still use advice until then. Thanks, bartbes (I'd give you karma, but now there's no karma)
B-Man99
Prole
Posts: 36
Joined: Wed Jul 25, 2012 10:51 pm
Location: Right behind you. I know you looked. Heck, even I looked

Re: Yet Again: Fails to index field "?"

Post by B-Man99 »

Update: bla bla bla

Edit: FIXED. THANK YOU FOR YOUR HELP
Post Reply

Who is online

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