I have been trying to retrieve the table that I created from a file, but it does not get retrieved in any format that I know how to use. I had it successfully save, and I believe I can retrieve it, but to convert that to a usable table is beyond me. Here is the table that I created in the previous program:
Admin,craniumkid22,xxxxx
User,miveck,yyyyy
Lights,0,false
7,false,false
Reactor,16384,true
Coolant,2048,true
4,1,nil
Macerator,16,false
Furnace,2,false
Compressor,8,false
Extractor,8192,false
The rows correspond to the correct items, but using my load function, I'm just not sure how to apply the results to the rest of my code. This is my loading code:
local function loadState()
local loadTable = {}
local file = fs.open("status", "r")
if file then
readLine = file.readLine()
while readLine do
local lineTable = {}
lineTable.type, lineTable.color, lineTable.status = string.match(readLine, "(%a+),(%a+),(%a+)")
if lineTable.type then
table.insert(loadTable, lineTable)
end
readLine = file.readLine()
end
file.close()
end
return loadTable
end
I thought I could simply do this:
table1 = loadState()
print(table1[1])
and it would print the first line, but I have no idea how… I am unable to use these lines without knowing how…