Posted 16 January 2014 - 04:47 PM
I am trying to write an interactive program that will be based completely off variables, how do I save variables in-between chunk loading and unloading and server restarts?
local file = fs.open(fileName,fileMode) -- use "w" fileMode to write files. Note that using "w" wipes the file clean when you open it.
file.writeLine(variable) --writes a line containing variable to the file
file.close() --closes the file when you are done with it
local file = fs.open(fileName,fileMode) -- use "r" filemode to read files
file.readLine() --this will return one line of the file each time you call it
file.close() -- and close when you are done
Those are the basics which should be all you need, but there's a few more things you can do with it which you can read about here