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

NVRAM

Started by tesla1889, 30 January 2013 - 01:02 PM
tesla1889 #1
Posted 30 January 2013 - 02:02 PM
Non-Volatile Random Access Memory?

doesn't have to be much. just 500 bytes or something like that.

possible API would just be the table nvram. it just wouldn't be lost when the computer shuts down.

example:

term.clear()
term.setCursorPos(1,1)
nvram.loginCount = (nvram.loginCount + 1)
for k,v in pairs(nvram)
do print(k .. ": " .. v)
end
producing on the screen:

loginCount: 42
username: tesla1889
passwordHash: 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
lastEdited: /foo/bar
Lyqyd #2
Posted 30 January 2013 - 03:15 PM
You could easily write an API to do this with a special file.
tesla1889 #3
Posted 30 January 2013 - 03:18 PM
the point is to do this without a file
Dlcruz129 #4
Posted 30 January 2013 - 03:21 PM
the point is to do this without a file

Why? You know files can be hidden.
ChunLing #5
Posted 30 January 2013 - 03:23 PM
The CC team has been working on implementing persistence for a while now, so that computers that are shutdown due to a chunk reload will resume their programs. For other cases, the fs API should be sufficient to saving information (and the idea that any of this is going to happen without there being files is missing some pretty basic understanding, I think).
tesla1889 #6
Posted 30 January 2013 - 03:37 PM
–snip–
(and the idea that any of this is going to happen without there being files is missing some pretty basic understanding, I think).

sorry if i wasnt being clear

my idea is for each computer folder to have a matching nvram file

this way, dan and cloudy are happy because users dont have read-only files and computers can store string and number values while shut down

Edit: yes, technically, the nvram file would be read-only, but there would only be one of them
ChunLing #7
Posted 30 January 2013 - 05:00 PM


What do you mean, it's a read-only file?
tesla1889 #8
Posted 30 January 2013 - 05:44 PM
minecraft/
[indent=1]saves/[/indent]
[indent=2]your_saved_world/[/indent]
[indent=3]computer/[/indent]
[indent=4]nvram/ *[/indent]
0
[indent=5]1[/indent]
[indent=5]2[/indent]

* this is where it probably should be saved

each file in the nvram folder would correspond to the computer with the same id number
immibis #9
Posted 30 January 2013 - 06:08 PM
This could be done in pure Lua, but it would be nice to have as a built-in API (written in Lua).
tesla1889 #10
Posted 30 January 2013 - 06:44 PM
the problem i'm foreseeing with writing it in lua is the possible deletion of the nvram file
Zoinky #11
Posted 30 January 2013 - 06:49 PM
the problem i'm foreseeing with writing it in lua is the possible deletion of the nvram file

You could hide it. Then, most people wouldn't delete it.
Lyqyd #12
Posted 30 January 2013 - 06:49 PM
As opposed to someone looping through and setting all the values to nil? There is no advantage here over using a file on the machine.
tesla1889 #13
Posted 30 January 2013 - 07:18 PM
i guess the way to make it better would be having to know the index to delete it
immibis #14
Posted 30 January 2013 - 08:51 PM
i guess the way to make it better would be having to know the index to delete it
What's the point in trying to protect your code from itself?
tesla1889 #15
Posted 31 January 2013 - 07:30 PM
allowing for multiple OSs to be installed on the same computer.
each OS (or shell, rather) would know its own nvram indices, but wouldn't know the others
Lyqyd #16
Posted 01 February 2013 - 04:53 AM
You seem to be perceiving advantages to having this be some special extra thing. There are none. This can (and should) be written in pure Lua. I disagree that this should be in the base install of ComputerCraft, but that call is up to the devs.
Dlcruz129 #17
Posted 01 February 2013 - 12:52 PM
allowing for multiple OSs to be installed on the same computer.
each OS (or shell, rather) would know its own nvram indices, but wouldn't know the others

Who uses multiple operating systems? Hell, I don't even use any custom operating systems.
ChunLing #18
Posted 01 February 2013 - 04:48 PM
More to the point, there is no reason that each operating system couldn't use its own hidden file for this purpose.
Dlcruz129 #19
Posted 01 February 2013 - 04:49 PM
More to the point, there is no reason that each operating system couldn't use its own hidden file for this purpose.

Agreed.
immibis #20
Posted 02 February 2013 - 06:42 PM
You seem to be perceiving advantages to having this be some special extra thing. There are none. This can (and should) be written in pure Lua. I disagree that this should be in the base install of ComputerCraft, but that call is up to the devs.
Should it be pure Lua included in the base install of ComputerCraft, though?
ChunLing #21
Posted 02 February 2013 - 07:37 PM
Generally the base install is things that are going to be used by most people (at some point). This strikes me as something that will be used by relatively few people, and I suspect that many of them would prefer writing their own implementation, since one of the intended features is to provide a degree of system security (having a standard version would tend to defeat that).
immibis #22
Posted 03 February 2013 - 01:45 AM
Generally the base install is things that are going to be used by most people (at some point). This strikes me as something that will be used by relatively few people, and I suspect that many of them would prefer writing their own implementation, since one of the intended features is to provide a degree of system security (having a standard version would tend to defeat that).
I thought of it as only a convenience thing. You can't stop other programs from reading and writing your files anyway, without overriding fs.
Alekso56 #23
Posted 03 February 2013 - 03:22 AM
herp, HTTP API anyone?
tesla1889 #24
Posted 03 February 2013 - 05:55 AM
–snip–

what, use it to post the NVRAM online?
tesla1889 #25
Posted 03 February 2013 - 05:57 AM
question: is there any way for rom programs to edit other rom files?

EDIT: stupid question, rom is shared by all computers, nvm
Cloudy #26
Posted 04 February 2013 - 12:07 AM
Nope. Can be made in pure Lua.
immibis #27
Posted 04 February 2013 - 12:16 AM
Nope. Can be made in pure Lua.
Why do we have io and disk and colours and gps and keys and parallel and rednet and textutils and vector?
Cloudy #28
Posted 04 February 2013 - 01:11 AM
For ease of use. The answer is no - what would be the point when persistence is planned eventually? I'm not going to add something like this purely because people can't/won't make it/download it themselves.
tesla1889 #29
Posted 04 February 2013 - 06:01 AM
–snippity snip–
persistence is planned eventually
–snippity snip–

oh, really?
nvm then, that's exactly what i need. cool beans, bro.