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

weird problem

Started by roosterhat, 09 June 2014 - 08:38 PM
roosterhat #1
Posted 09 June 2014 - 10:38 PM
Error: test:273: attempt to index ? (a nil value)
its weird it will keep saying this until i comment out the 3 variables in the pages tabel run it, then uncomment them and run it again. I think it has something to do with cc or lua keeping track of variables or something because it only happens when i restart the computer or open minecraft for the first time

Code: http://pastebin.com/JDXR5XBb
CometWolf #2
Posted 09 June 2014 - 10:42 PM
Since content is being defined at that point in the code, you are indeed attempting to index nil. You can't index the value of a table you are creating within it's own definition.
roosterhat #3
Posted 09 June 2014 - 10:44 PM
oh ya, i guess i could add that to the table after if created all of the pages
Bomb Bloke #4
Posted 10 June 2014 - 02:05 AM
The reason why it works after running it with the lines commented is that you're not localising your tables, functions, nor most of your other variables for that matter.

This means that when the script ends they stay loaded in RAM, and would in fact be available to other scripts were they to look for them.