• Advertisement
Sign in to follow this  

[Lua] Error when automatically creating a table

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement