58 posts
Posted 17 February 2013 - 08:09 AM
My question is how would I save a table to a file, so that later i could open that file read it(which i also need help with) and then set the contents of the table to different variable. Could anyone help me out?
194 posts
Location
Spain
Posted 17 February 2013 - 08:13 AM
you can serialize a table (convert it to a string) and then save it to a file:
--Save table
t = {"1","2","3","4"}
hWrite = fs.open("fileName", "w")
hWrite.write(textutils.serialize(t))
hWrite.close()
--Load the table
hRead = fs.open("fileName", "r")
t = textutils.unserialize(hRead.readLine())
hRead.close()
58 posts
Posted 17 February 2013 - 08:22 AM
Okay thanks for the help, was just unclear on how to go about it.