Page 2 of 2
Re: Error claims a value is nil, which makes no sense
Posted: Fri Sep 01, 2017 2:42 am
by raidho36
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.
Re: Error claims a value is nil, which makes no sense
Posted: Fri Sep 01, 2017 5:41 am
by dyl4n130
raidho36 wrote: ↑Fri Sep 01, 2017 2:42 am
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.
Code: Select all
for i = 1, 20 do
table.insert(rX, love.math.random(100, 110))
table.insert(rY, love.math.random(100, 110))
table.insert(rS, love.math.random(1, 20))
end
this is all the code that generates the tables so I dont see how there could be a nil in there. This is absolutley baffling to me
Re: Error claims a value is nil, which makes no sense
Posted: Fri Sep 01, 2017 6:40 am
by raidho36
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 use an algorithm that doesn't involves deleting elements mid-loop.
Re: Error claims a value is nil, which makes no sense
Posted: Fri Sep 01, 2017 6:54 am
by dyl4n130
raidho36 wrote: ↑Fri Sep 01, 2017 6:40 am
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 use an algorithm that doesn't involves deleting elements mid-loop.
maybe i could just make an array that marks each table element to remove then do it after the loop finishes?
Re: Error claims a value is nil, which makes no sense
Posted: Fri Sep 01, 2017 7:22 am
by raidho36
You could do that, yes.