This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Klausar's profile picture

How to save variables?

Started by Klausar, 20 October 2012 - 12:35 PM
Klausar #1
Posted 20 October 2012 - 02:35 PM
Hey CC-Community,
I want to make a more advanced program. For this I need to save variables if that is possible. For example: I want to register a name at the first startup of the program, I would make

x = io.read()

but how can I make it so that the x always stays the same? Is that possible? Thanks for your help :)/>/>
Espen #2
Posted 20 October 2012 - 02:50 PM
You could store its value to a file.
Advert made a nice API for storing data: http://www.computerc...save-your-datas

It takes away the need to know how to do IO-Operations on files yourself.
Or did you explicitly want to know how to do it yourself? In that case I'd suggest looking into the fs api.
Type "help fs" in ComputerCraft, or look into the wiki: http://computercraft...?title=Fs_(API)