[FIXED] Yet Again: Fails to index field "?"
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- 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 "?"
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 114 times
Last edited by B-Man99 on Fri Feb 22, 2013 3:26 am, edited 1 time in total.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Yet Again: Fails to index field "?"
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):
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.
Code: Select all
print(grid[x])
print(grid[x][y])
print(leveldata[i])
-
- 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 "?"
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)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):
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.Code: Select all
print(grid[x]) print(grid[x][y]) print(leveldata[i])
-
- 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 "?"
Update: bla bla bla
Edit: FIXED. THANK YOU FOR YOUR HELP
Edit: FIXED. THANK YOU FOR YOUR HELP
Who is online
Users browsing this forum: Semrush [Bot] and 3 guests