Public Group

[Lua] Error when automatically creating a table

This topic is 2465 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am making a text-based Minesweeper for lua, and I am using Tables for graphics.
This is what I use to initialize it:
for i = 1, 16 do a = {a} a = G end

However, I get this error:
lua: Minesweeper.lua:7: attempt to index global 'a' (a nil value) stack traceback: Minesweeper.lua:7: in main chunk [C]: ? >Exit code: 1

As far as I can tell, my code should be correct.
Can someone please correct my idiotic code? Haven't programmed in about a year.

Share on other sites
Looks like a is undefined.

you have to define a somewhere atleast like this

a={}

that creates a new table called a, in global namespace.

local a={}

will create one in local namespace..

Good Luck!

-ddn

• 10
• 16
• 14
• 18
• 15