Jump to content
  • Advertisement
Sign in to follow this  

[Lua] Error when automatically creating a table

This topic is 2616 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

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
Looks like a is undefined.

you have to define a somewhere atleast like this


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

local a={}

will create one in local namespace..

Good Luck!


Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!