Love crashes without error, don't know whats wrong 7.1/7.2

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.
Socram
Prole
Posts: 3
Joined: Thu Aug 05, 2010 1:50 am

Love crashes without error, don't know whats wrong 7.1/7.2

Post 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? :shock:

If you need any other information or want to see some other code let me know.

Thank you for your time!
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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:

Code: Select all

for i = 1, #str do
  -- ...
end
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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...)
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post by Robin »

Where is self.terrainMap defined? I have a suspicion it is

Code: Select all

self.terrainMap = {{}}
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.
Help us help you: attach a .love.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post by Robin »

Oh. But Socram, if you gave us a .love of your game, that would help.
Help us help you: attach a .love.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Love crashes without error, don't know whats wrong 7.1/7

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests