ipairs not working correctly

Started by pjals_but_noisy, Oct 24, 2021, 12:06 PM

Previous topic - Next topic

pjals_but_noisy

code: https://pastebin.com/PZq9uhpH

for some some reason, this code doesn't work correctly, even though the table goes like
{
 1={
  ...
 }
 ...
}

if you replace ipairs with pairs, it works correctly
a

Lupus590

Are you sure that you are using numeric indexes and not having numbers in strings?

pjals_but_noisy

its a number, not a string (tested with type(index))
a

Lupus590

#3
Can you upload all of the required code and some example data to test with?

I'll try to replicate the issue and see what I can figure out for you.

Also, what version of the mod are you using? And are you on forge or fabric?

pjals_but_noisy

#4
here is test data, run playnbs.lua and input "EDA.nbs": https://envs.sh/EDG.zip (oh and for some reason theres a endianness issue so this is not for production!) (i think i switched ipairs to pairs, so you  will need to do that manually)
a

Lupus590

ipairs starts from 1 and goes until the first nil, your indexes don't start at 1 and so ipairs sees nil when it looks at index 1 and then stops as it assumes that the table is empty.

You might need to restructure how you are storing your table data.