I'm trying to wrap my head around openPeripherals but I'm having issues working out how to access the info shown in the table created when using "getTankInfo()" How can I see it?
1
Using Tables?
Started by makeme, Feb 26 2014 09:31 PM
2 replies to this topic
#1
Posted 26 February 2014 - 09:31 PM
#2
Posted 26 February 2014 - 10:17 PM
Just use a for loop to get all the elements in a table
if the field is a number, use table[key]
for k,v in pairs(table) do print("["..k.."] = "..v) endTo acess the fields, just use table.key
if the field is a number, use table[key]
#3
Posted 27 February 2014 - 11:20 AM
Also, you can use variable as table key, for example:
You can think about square brackets in tables as "get value from stuff inside and use it as table key".
local key = "black" term.setBackgroundColor(colors[key])
You can think about square brackets in tables as "get value from stuff inside and use it as table key".
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users