This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Nhorr's profile picture

Trying to reference another file/program as a table, getting "attempt to index ?" error.

Started by Nhorr, 27 July 2016 - 08:59 PM
Nhorr #1
Posted 27 July 2016 - 10:59 PM
Back again with yet another problem I can't make sense of. I understand the error refers to the program not being able to reference the target due to it not existing, but as far as I can understand, it should be able to reference the target without a problem.

My desktop code is supposed to reference a file named .nhuicfg for color settings/etc, creating a table based off of the contents of .nhuicfg for desktop to reference (based on a similar forum post). Thing is, when the supposed table is first called up for a value, it returns an index nil error at line 62. Perhaps the table containing .nhuicfg's values isn't constructing at all? I can't get it to work, but then again I never understood tables quite well (I need to get more practice in with them)

The desktop portion of my UI can be seen here: http://pastebin.com/JUhsDLDd
The .nhuicfg file it references can be seen here: http://pastebin.com/mbD7EU2J
Lastly, the UI installation program can be found here: http://pastebin.com/qExuNAUg

I haven't had much time to search the issue as of late, but I haven't been able to find much on this particular issue. Any point in the right direction would be much appreciated.

Many thanks in advance!
Edited on 27 July 2016 - 09:00 PM
KingofGamesYami #2
Posted 27 July 2016 - 11:17 PM
The .nhuicfg file doesn't contain a serialized table, therefor unserialize returned nil.

Also, correct me if I'm wrong since I haven't used io much, but doesn't file:read() only return one line of the file?
Edited on 27 July 2016 - 09:21 PM
The_Cat #3
Posted 28 July 2016 - 10:32 AM
The .nhuicfg file doesn't contain a serialized table, therefor unserialize returned nil.
Not related to OP. But in the serialized wiki, the first code example has an error. (Unsure how/if I can edit it.)
Edited on 28 July 2016 - 08:32 AM
Lupus590 #4
Posted 28 July 2016 - 03:58 PM
The .nhuicfg file doesn't contain a serialized table, therefor unserialize returned nil.
Not related to OP. But in the serialized wiki, the first code example has an error. (Unsure how/if I can edit it.)

I think I fixed it, it was also in the second example
Nhorr #5
Posted 29 July 2016 - 09:44 PM
The .nhuicfg file doesn't contain a serialized table, therefor unserialize returned nil.

Also, correct me if I'm wrong since I haven't used io much, but doesn't file:read() only return one line of the file?

Thanks for the reply (only just now got around to checking for replies on this). I'll get around to making it contain a serialized table and test things out in the next few days. I'll be back with the results when I do. Again, thanks for the insight!

And sadly I haven't used it enough to know the exact answer, but I guess we'll find out soon enough when I try to test things out.