I have following lua code that prints out the Mac Addresses of a device.
local sc = Command.Scan.create()
local devices = sc:scan()
local topicMac
local list = {}
for _,device in pairs(devices) do
print(device:getMACAddress())
list[device] = device:getMACAddress()
end
topicMac = list[0]
print(topicMac)
Since there are several addresses and they are listed in a table, I would like to save only the first one into the local variable "topicMac". I tried reaching that first value by adding the first index (0 or 1) in the array.
Why do I get nil as return?
local. - Nicol Bolaslist, or can you throw out everything except the first item? If you don't need the wholelist, @Senor's answer is correct. - lutherdeviceslook like? what is the "first" MAC address to you, or do you just want any mac address form the list? why do you need a list in the first place if you just want the first address? - DarkWiiPlayer