ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: TheTinyDeskEngineer on Aug 19, 2021, 12:56 AM

Title: gol.lua:17: attempt to index field '?' (a nil value)
Post by: TheTinyDeskEngineer on Aug 19, 2021, 12:56 AM
Pastebin: X7K6ekPE

I'm trying to recreate Conway's Game Of Life in Computercraft, and I've gotten the part of drawing cells onto a grid working fine, but when I press Enter to start the simulation it gives me this error.

I used Notepad to search for question marks, but it can't find any.

The line it refrences (and the ones before and after it) are:
    for i = 1, #offsets do
        if grid[offsets[i][1]][offsets[i][2]] ~= nil then
            count = count + grid[offsets[i][1]][offsets[i][2]]
Title: gol.lua:17: attempt to index field '?' (a nil value)
Post by: Lupus590 on Aug 19, 2021, 10:25 AM
The question mark means that Lua couldn't figure out the name of the variable that was being indexed. Put another way, one of the tables that you are indexing is nil, unfortunately, you have several tables (including those within other tables) on that line so it's going to be a bit of a pain to pick through and find out what is nil.