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

SOLVED]Reading / Writing

Started by Rangicus, 21 September 2012 - 09:23 PM
Rangicus #1
Posted 21 September 2012 - 11:23 PM
I was wondering if there was anyway to have memory stored over different programs, like if you want to have something name you on initial boot it will say Whats your name, other times it will say oh hey so and so but you can do it with like multiple things?
Thanks
Cranium #2
Posted 21 September 2012 - 11:38 PM
You can do one of two things:
  1. Write a variable to a global value. Not recommended, but can be used.
  2. Write to a separate file in ComputerCraft. Harder to do, but more reliable.
MysticT #3
Posted 21 September 2012 - 11:39 PM
3. Make an api that stores the value.
Rangicus #4
Posted 21 September 2012 - 11:42 PM
I knew what the options were I just have no idea how to do those things
MysticT #5
Posted 21 September 2012 - 11:51 PM
1. Simply make a variable that's not local. (if you don't know how to do this, you really need to learn lua before).
2. You'll need the fs api, take a look at the wiki to learn how to use it.
3. An api is a file that contains functions. Just make one that lets you store a value.
Steelsouls #6
Posted 22 September 2012 - 12:09 PM
If you want to use the reliable method of saving to a file, this tutorial should help.

http://www.computercraft.info/forums2/index.php?/topic/3923-basic-file-io-learn-how-to-save-data/page__fromsearch__1