Search found 24 matches

by dyl4n130
Fri Sep 01, 2017 6:54 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

I did a super basic test and it only errors after removing some table elements by attempting to index an out of range element, as I said. Because of the way your loop works, there's no way to set it up so it wouldn't crash. You will need to either manually check if the value is nil every time, or u...
by dyl4n130
Fri Sep 01, 2017 5:41 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

All I can say then, it doesn't show error screen unless there is an error. There is a nil in your tables somewhere. There is always nil past the range, and there could be one in the middle. for i = 1, 20 do table.insert(rX, love.math.random(100, 110)) table.insert(rY, love.math.random(100, 110)) ta...
by dyl4n130
Fri Sep 01, 2017 2:31 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

raidho36 wrote: Fri Sep 01, 2017 2:02 am Then it must be your other table. If it's not the same length it would return nil on trailing elements.
all the tables have to be the same length. they are all defined within the same for loop in love.load
by dyl4n130
Fri Sep 01, 2017 2:00 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

Sir_Silver wrote: Fri Sep 01, 2017 1:47 am What raidho means is, instead of iterating from 1 to the # of your table, iterate from the # of your table to 1 stepping by -1:

Code: Select all

for i = #my_table, 1, -1 do

end
thats what i thought he meant, didnt work though
by dyl4n130
Fri Sep 01, 2017 2:00 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

raidho36 wrote: Fri Sep 01, 2017 1:29 am If you remove a table element, it will be shorter than it was when you started looping, so last loop indices will be out of range and produce nil. I'm sure that's your problem. Just loop it backwards.
did that, same problem. it returns nil before table elements start getting removed
by dyl4n130
Fri Sep 01, 2017 1:24 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

raidho36 wrote: Fri Sep 01, 2017 1:13 am If you want to remove table elements mid-loop you need to loop backwards.
could you elaborate? I dont think that is the problem since the program crashes before it even gets to the table.remove
by dyl4n130
Fri Sep 01, 2017 1:03 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Re: Error claims a value is nil, which makes no sense

So the problem is definitley in the `n` for loop. In other areas I replaced n with 1 and it ran fine. So the loop that does i works fine, but the exact same loop with a differnent letter doesnt work. This is really annoying
by dyl4n130
Fri Sep 01, 2017 1:01 am
Forum: Support and Development
Topic: Error claims a value is nil, which makes no sense
Replies: 14
Views: 9616

Error claims a value is nil, which makes no sense

Everytime I attempt to run my code I get an error that says a value in my if statement is nil. The if statement in question: elseif rX[i] < rX[n] + 2 and rX[n] < rX[i] + 2 and rY[i] < rY[n] + 2 and rY[n] < rY[i] + 2 then Ive managed to narrow it down to it thinking that rX[n] is nil. The absolutely ...
by dyl4n130
Tue Aug 29, 2017 12:47 pm
Forum: Support and Development
Topic: How would I go about drawing the same object multiple times?
Replies: 10
Views: 9319

Re: How would I go about drawing the same object multiple times?

When you try to access an index of a table whose value is nil,, if that table has a metatable which has an __index metamethod, it will invoke the __index metamethod. Here's what happens without the use of a metatable: local my_table = {} print(my_table[1]) --prints nil, because there is no value at...
by dyl4n130
Tue Aug 29, 2017 12:43 pm
Forum: Support and Development
Topic: Strange issue - my function always thinks it is selecting something when im not
Replies: 7
Views: 4315

Re: Strange issue - my function always thinks it is selecting something when im not

Would you be so kind as to upload a .love file of your game, it would be much easier to debug that way. If you aren't sure how to do that, you just have to zip up your main.lua with any other files you have and rename the .zip to .love everything is super unstructured and spelled wrong just ignore ...