I am attempting to learn Lua and a friend of mine has given me some code to help me learn tables and table manipulation and I am currently having issues with doing the following with this table he has given me.
- Write a program to count how many spotted dogs are in the table.
- Write a program to count how many of each breed there are.
- Write a program to invert all of the 'Spotted' in a new table called
tblSpottedDogs
He has given me some hints for 3, which I'll attempt when I get to it, so that is less of an issue for now, but 1 and 2 I am having issues with.
local tblDogs = {
{
['Name'] = 'Jeffey',
['Breed'] = 'Jack Russell Terrier',
['Colour'] = 'White and Black',
['Spotted'] = true
},
{
['Name'] = 'Spot',
['Breed'] = 'Jack Russell Terrier',
['Colour'] = 'White and Brown',
['Spotted'] = false
},
{
['Name'] = 'Jeffey',
['Breed'] = 'Jack Russell Terrier',
['Colour'] = 'White and Red',
['Spotted'] = true
},
{
['Name'] = 'Snitzel',
['Breed'] = 'Dachshund',
['Colour'] = 'Brown',
['Spotted'] = false
},
{
['Name'] = 'Hugo',
['Breed'] = 'Dachshund',
['Colour'] = 'Dark Brown',
['Spotted'] = false
},
{
['Name'] = 'Freedum',
['Breed'] = 'Eagle',
['Colour'] = 'Brown Feathers',
['Spotted'] = true
},
{
['Name'] = 'Grrrrrrrrrrrrrrrrrrrrrrrr',
['Breed'] = 'Bear',
['Colour'] = 'Brown',
['Spotted'] = false
},
{
['Name'] = 'Stinky',
['Breed'] = 'Skunk',
['Colour'] = 'White and Black',
['Spotted'] = false
},
{
['Name'] = 'Gary',
['Breed'] = 'Golden Retriever',
['Colour'] = 'Golden Yellow',
['Spotted'] = false
},
{
['Name'] = 'Stinky',
['Breed'] = 'Cat in the Hat',
['Colour'] = 'Cat',
['Spotted'] = false
}
}