Error claims a value is nil, which makes no sense

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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post 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.
dyl4n130
Prole
Posts: 24
Joined: Sat Jul 29, 2017 6:48 am

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

Post 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
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post 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.
dyl4n130
Prole
Posts: 24
Joined: Sat Jul 29, 2017 6:48 am

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

Post 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?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post by raidho36 »

You could do that, yes.
Post Reply

Who is online

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