Ok, let's say you've got a table and you've stored it in "myTable". You've no idea what's in it but you want to find out.
In the table are one or more variables, referred to as "keys". The content of these variables can be anything: strings, numerals, functions, or even more tables.
First off, you want to print out a list of what the table contains. Create a loop:
for key,content in pairs(myTable)
print(key.." is a "..type(content))
end
This loop repeats once for every variable in the table. At the start of each iteration, the "key" variable gets assigned the name of the current variable in the table, and the "content" variable gets the content of the current variable in the table.
Let's say you run this and you get told that there's a key in there called "name", it's a string, and you want to print that string's contents. You'd call:
print(myTable.name)
Or:
print(myTable["name"])
The latter method is
required if the key is a numeral, or has spaces in its name.
If you found another table in myTable (say it was called "1"), you'd then loop through
that and see what's in it:
for key,content in pairs(myTable[1])
print(key.." is a "..type(content))
end
If you found a function in the [1] table inside "myTable" called eg "somefunction", then it'd be called thusly:
myTable[1].somefunction()
And so on.
Generally though, when you've got an unfamiliar table with functions in it, it's time to hunt down the documentation for whatever API it was that gave it to you - functions usually expect you to hand them parameters, and trying to work out what
those are on your own is a fool's errand. However, bear in mind that APIs themselves load in as tables (and so do wrapped peripherals, for that matter), so if you use the above example loop on eg "paintutils" instead of "myTable" - then hey presto, you've printed a list of the functions in the
paintutils API!