Problem with inserting table into table
Problem with inserting table into table
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.
-
- Prole
- Posts: 15
- Joined: Thu Dec 11, 2008 5:44 am
Re: Problem with inserting table into table
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?
have you tried just doing bigTable[#bigTable+1] = {blah} rather than using insert?
Re: Problem with inserting table into table
Yeah, that's my normal approach, i then tried using table.insert, and no change.
Re: Problem with inserting table into table
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.
Because man, that is weird.
-
- Prole
- Posts: 15
- Joined: Thu Dec 11, 2008 5:44 am
Re: Problem with inserting table into table
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.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.
How big is the table, and does it happen whenever you insert to it or only when you hit a certain barrier?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Problem with inserting table into table
Apparently, you did.TacticalPenguin wrote:seriously who needs 7D tables
But yeah, that is weird.
Help us help you: attach a .love.
Re: Problem with inserting table into table
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.
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.
-
- Prole
- Posts: 15
- Joined: Thu Dec 11, 2008 5:44 am
Re: Problem with inserting table into table
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?
and have you tried printing every var in the explode func to see exactly what's being computed/calculated/done?
Re: Problem with inserting table into table
I've tried it both ways.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'll do that when i get home from work, but I'm skeptical I'll see anything I don't expect.TacticalPenguin wrote:and have you tried printing every var in the explode func to see exactly what's being computed/calculated/done?
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?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Problem with inserting table into table
I'm not sure, but I think it might be something processor-dependent.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?
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.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests