Page 1 of 2
Love crashes without error, don't know whats wrong 7.1/7.2
Posted: Thu May 05, 2011 5:17 am
by Socram
Hi, so I've tried this out on both 7.1 and 7.2 with no avail, so its nothing version specific.
I've been working on a little game and it is coming a long nicely but I've come across a crash that I can not seem to fix, or find a reason for. I know the exact offending code but I just don't know why it is crashing. The bit of code is:
Code: Select all
for p=1, # do
for o=1, # do
self.terrainMap[o][p] = terrainChunk:new(256,512,512,512)
end
end
Everything works fine how it is as long as i keep the two #'s above at 1 (which is pointless...) however if I try to store more than one "terrainChunk" (a functioning object defined elsewhere) within the table it crashes. I also know that the table is set up correctly because I was able to create any old 2d array when I changed the assignment to a string or integer.
Each "terrainChunk" is an object that is essentially a 2d table that consists of a bunch of individual square objects, so this "terrainMap" would be a table of tables of objects. Could there be some sort of memory issues or something? Does lua or love have some sort of issue on 3d tables? or I guess in this case it's 4d?
If you need any other information or want to see some other code let me know.
Thank you for your time!
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 5:41 am
by Lafolie
As far as I know the only use of # is to read the length of a table. You should put:
Code: Select all
for i = 1, # table_to_check do
--blah
end
Although this could probably be done even tidier with ipairs.
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 7:32 am
by vrld
Do you have the .love file so we can have a look at the it ourselves? Without that we can only guess it's something that terrainChunk:new() does.
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 7:53 am
by BlackBulletIV
Lafolie wrote:As far as I know the only use of # is to read the length of a table. You should put:
Code: Select all
for i = 1, # table_to_check do
--blah
end
Although this could probably be done even tidier with ipairs.
It is also used to get the length of a string, a better alternative to string.len:
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 8:03 am
by vrld
Guys, the # is a placeholder for a number, not real code:
Socram wrote:Everything works fine how it is as long as i keep the two #'s above at 1 (which is pointless...)
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 8:53 am
by Robin
Where is self.terrainMap defined? I have a suspicion it is
which is not good.
Maybe
Code: Select all
for o=1, # do -- notice I swapped o and p
self.terrainMap[o] = {}
for p=1, # do
self.terrainMap[o][p] = terrainChunk:new(256,512,512,512)
end
end
will work.
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 9:07 am
by vrld
That would produce an error, about trying to index a nil value. But LÖVE crashes without error, which points to a bug in LÖVE.
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 2:19 pm
by Robin
Oh. But Socram, if you gave us a .love of your game, that would help.
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 2:39 pm
by Lafolie
Robin wrote:Oh. But Socram, if you gave us a .love of your game, that would help.
Do you think it would be worth making an announcement/sticky thread regarding this? Not so much a forum rules, but a guideline giving people tips on how to help us help them. The more information they give us the faster their problem will inevitably be solved.
Re: Love crashes without error, don't know whats wrong 7.1/7
Posted: Thu May 05, 2011 6:53 pm
by Robin
Lafolie wrote:Do you think it would be worth making an announcement/sticky thread regarding this? Not so much a forum rules, but a guideline giving people tips on how to help us help them. The more information they give us the faster their problem will inevitably be solved.
It might very well. I have been thinking that a wiki page on this would be useful, but a sticky will probably be read more often.