ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: pjals_but_noisy on Oct 24, 2021, 12:06 PM

Title: ipairs not working correctly
Post by: pjals_but_noisy on Oct 24, 2021, 12:06 PM
code: https://pastebin.com/PZq9uhpH (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
Title: ipairs not working correctly
Post by: Lupus590 on Oct 24, 2021, 06:28 PM
Are you sure that you are using numeric indexes and not having numbers in strings?
Title: ipairs not working correctly
Post by: pjals_but_noisy on Oct 25, 2021, 11:53 AM
its a number, not a string (tested with type(index))
Title: ipairs not working correctly
Post by: Lupus590 on Oct 25, 2021, 09:11 PM
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?
Title: ipairs not working correctly
Post by: pjals_but_noisy on Oct 26, 2021, 08:19 AM
here is test data, run playnbs.lua and input "EDA.nbs": https://envs.sh/EDG.zip (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)
Title: ipairs not working correctly
Post by: Lupus590 on Oct 26, 2021, 10:08 AM
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.