I'll start by apologizing for not being a programmer. I had some C++ in high school, more than a decade ago.
The server administrator of a game I play has provided a Lua file listing current in-spawn resources, and I want to be able to print the data I want into a format I want. Here's what the table looks like (only a small portion from the beginning):
and it goes on and on and on like that.
What I want to output is:
Ababuglu,Conductive Borcarbitic Copper,184,539,906,86,349,469,344,598
Abam,Talusian Flower Fruit,284,686,204,845
So, basically:
Print the value of the key “name”
Print a comma
Print the second-to-last string in the “classes” key
Print each of the numbers in the attributes key, preceded by a comma
I'm sure it's not mega complicated for someone who knows what they're doing, so can anyone point me in the right direction? I'm not sure if the "things" after classes & attributes are considered subtables. There are no = signs, so I don't know.
The server administrator of a game I play has provided a Lua file listing current in-spawn resources, and I want to be able to print the data I want into a format I want. Here's what the table looks like (only a small portion from the beginning):
resources = {
{
name = "Abacadulis",
type = "petrochem_fuel_solid_unknown",
classes = {
{"Inorganic", "inorganic"},
{"Mineral", "mineral"},
{"Solid Petrochem Fuel", "fuel_petrochem_solid"},
{"Unknown Solid Petrochem Fuel", "petrochem_fuel_solid_unknown"},
},
attributes = {
{"res_decay_resist", 904},
{"res_potential_energy", 297},
{"res_quality", 35},
},
zoneRestriction = "",
surveyToolType = 6,
containerCRC = 2431128978,
},
{
name = "Abam",
type = "fruit_flowers_talus",
classes = {
{"Organic", "organic"},
{"Flora Resources", "flora_resources"},
{"Flora Food", "flora_food"},
{"Seeds", "seeds"},
{"Fruit", "fruit"},
{"Flowers", "fruit_flowers"},
{"Talusian Flower Fruit", "fruit_flowers_talus"},
},
attributes = {
{"res_decay_resist", 284},
{"res_flavor", 686},
{"res_potential_energy", 204},
{"res_quality", 845},
},
zoneRestriction = "talus",
surveyToolType = 3,
containerCRC = 1349101341,
},
and it goes on and on and on like that.
What I want to output is:
Ababuglu,Conductive Borcarbitic Copper,184,539,906,86,349,469,344,598
Abam,Talusian Flower Fruit,284,686,204,845
So, basically:
Print the value of the key “name”
Print a comma
Print the second-to-last string in the “classes” key
Print each of the numbers in the attributes key, preceded by a comma
I'm sure it's not mega complicated for someone who knows what they're doing, so can anyone point me in the right direction? I'm not sure if the "things" after classes & attributes are considered subtables. There are no = signs, so I don't know.