Problem with inserting table into table

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Matkins
Citizen
Posts: 53
Joined: Mon Mar 23, 2009 5:12 pm

Problem with inserting table into table

Post by Matkins »

I have a table in my code which holds tables, each nested table has several elements holding numbers. When i try to add new tables to the table in real time i suddenly find that ALL the elements in ALL the nested tables equal nan. Does anyone know what could be causing this? I've not encountered it before.
TacticalPenguin
Prole
Posts: 15
Joined: Thu Dec 11, 2008 5:44 am

Re: Problem with inserting table into table

Post by TacticalPenguin »

eh that's a bit odd and I can't say I've ever had that problem

have you tried just doing bigTable[#bigTable+1] = {blah} rather than using insert?
Matkins
Citizen
Posts: 53
Joined: Mon Mar 23, 2009 5:12 pm

Re: Problem with inserting table into table

Post by Matkins »

Yeah, that's my normal approach, i then tried using table.insert, and no change.
User avatar
bmelts
Party member
Posts: 380
Joined: Fri Jan 30, 2009 3:16 am
Location: Wiscönsin
Contact:

Re: Problem with inserting table into table

Post by bmelts »

If you post your code to the loveclub pastebin (http://loveclub.pastebin.com), I (or one of our resident Lua masters) can take a look and figure out what's wrong.

Because man, that is weird.
TacticalPenguin
Prole
Posts: 15
Joined: Thu Dec 11, 2008 5:44 am

Re: Problem with inserting table into table

Post by TacticalPenguin »

anjo wrote:If you post your code to the loveclub pastebin (http://loveclub.pastebin.com), I (or one of our resident Lua masters) can take a look and figure out what's wrong.

Because man, that is weird.
My thoughts exactly, I've done quite a bit of ridiculous table usage (seriously who needs 7D tables) and never had anything like this happen.

How big is the table, and does it happen whenever you insert to it or only when you hit a certain barrier?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Problem with inserting table into table

Post by Robin »

TacticalPenguin wrote:seriously who needs 7D tables
Apparently, you did. :P

But yeah, that is weird.
Help us help you: attach a .love.
Matkins
Citizen
Posts: 53
Joined: Mon Mar 23, 2009 5:12 pm

Re: Problem with inserting table into table

Post by Matkins »

Ok, my entire program (so far) is in the paste bin http://loveclub.pastebin.com/m2e0723a1

The line where I insert into the table is 115. Its inside my explode() function which will get called when two bodies greater than radius 1 collide, which should be pretty soon after you run this if its as deterministic as i hope.

At the top of the window i'm drawing one of the sub table's elements that ends up being nan, and under that i'm drawing the number of elements in the parent table, which increases as expected.

I hope the code is easy to follow. Thanks for your help.
TacticalPenguin
Prole
Posts: 15
Joined: Thu Dec 11, 2008 5:44 am

Re: Problem with inserting table into table

Post by TacticalPenguin »

IDT theres some kind of reason why it would matter but maybe try ditching the local new value and just putting the table right there in the table.insert?
and have you tried printing every var in the explode func to see exactly what's being computed/calculated/done?
Matkins
Citizen
Posts: 53
Joined: Mon Mar 23, 2009 5:12 pm

Re: Problem with inserting table into table

Post by Matkins »

TacticalPenguin wrote:IDT theres some kind of reason why it would matter but maybe try ditching the local new value and just putting the table right there in the table.insert?
I've tried it both ways.
TacticalPenguin wrote:and have you tried printing every var in the explode func to see exactly what's being computed/calculated/done?
I'll do that when i get home from work, but I'm skeptical I'll see anything I don't expect.

I don't know if it's a big deal but I've been working on a Mac at home, but I've just tried this script on windows and instead of getting nan i get -1.#IND
What on earth could that mean?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Problem with inserting table into table

Post by Robin »

Matkins wrote:I don't know if it's a big deal but I've been working on a Mac at home, but I've just tried this script on windows and instead of getting nan i get -1.#IND
What on earth could that mean?
I'm not sure, but I think it might be something processor-dependent.

OK, I have no clue, but I'm pretty sure both NaN and -1.#IND (btw, not #INF?) are just two ways to say your computer could not do the math.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests