Search code examples
lualua-tablelove2d

Creating Lua tables as like the following


I'm trying to design such a table in lua using love2d. While I read a lot of tutorials about Lua I couldn't manage to create such a table as I didn't understand the concept. can anyone help me in creating this table?

enter image description here


Solution

  • defining:

    YourTable = {
      [1] = {Color1='Red',  Color2='Blue', Result='Yellow'},
      [2] = {Color1='Blue', Color2='Red',  Result='Orange'},
      [3] = ...
    }
    

    accessing:

    print(YourTable[2].Color1)