Here is an example of the table that I'm having problems with:
Spoiler
How do I access the values stored in the "Tanks" array? I have never worked with a table thats formatted table.index = { { k = v } }
Here is the solution I've found for now. Can anyone improve on it? I'm not to fond of the nested loops.
local function getDetails()
tDetails = {}
for _,targetName in pairs(tTargets) do
results = sens.getTargetDetails(targetName)
tTanks = results.Tanks
for _,tank in pairs(tTanks) do
for k,dets in pairs(tank) do
if tostring(k) == "Name" then tankName = tostring(dets)
elseif tostring(k) == "Amount" then sAmount = tostring(dets)
elseif tostring(k) == "Capacity" then sCapacity = tostring(dets)
end
end
if tankName then
if tankName == "jet fuel" then tankName = "jet_fuel" end
tDetails[tankName] = { ["Amount"] = sAmount, ["Capacity"] = sCapacity }
end
end
end
return tDetails
end
Edited by Cycomantis, 21 July 2014 - 04:00 AM.












