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

Table references throw errors after a certain point

Started by InsaneInTheMembrane, 21 June 2015 - 09:31 PM
InsaneInTheMembrane #1
Posted 21 June 2015 - 11:31 PM
I'm trying to implement Conway's Game of Life in Computercraft, which requires having two field tables; one to hold the field that is displayed, and one to hold the new cell values during the update process. The field that is displayed (simply called "field" in the code) works fine throughout the entire script, but the second (called newfield) spontaneously stops working and terminates the program with: "test:78: attempt to index ? (a number value)." The relevant function is "updateField." The print functions are for debugging.

source: http://pastebin.com/kyJBAZHD
Lyqyd #2
Posted 22 June 2015 - 01:04 AM
One leg of your if tree in the inner loop sets newfield to 0. You probably meant to set newfield[x][y] to 0 instead.