404 posts
Location
St. Petersburg
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
8543 posts
Posted 30 January 2013 - 03:15 PM
You could easily write an API to do this with a special file.
404 posts
Location
St. Petersburg
Posted 30 January 2013 - 03:18 PM
the point is to do this without a file
1619 posts
Posted 30 January 2013 - 03:21 PM
the point is to do this without a file
Why? You know files can be hidden.
2005 posts
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).
404 posts
Location
St. Petersburg
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
2005 posts
Posted 30 January 2013 - 05:00 PM
…
What do you mean, it's a read-only file?
404 posts
Location
St. Petersburg
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
997 posts
Location
Wellington, New Zealand
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).
404 posts
Location
St. Petersburg
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
144 posts
Location
Wellington, New Zealand
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.
8543 posts
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.
404 posts
Location
St. Petersburg
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
997 posts
Location
Wellington, New Zealand
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?
404 posts
Location
St. Petersburg
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
8543 posts
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.
1619 posts
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.
2005 posts
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.
1619 posts
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.
997 posts
Location
Wellington, New Zealand
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?
2005 posts
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).
997 posts
Location
Wellington, New Zealand
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.
66 posts
Posted 03 February 2013 - 03:22 AM
herp, HTTP API anyone?
404 posts
Location
St. Petersburg
Posted 03 February 2013 - 05:55 AM
–snip–
what, use it to post the NVRAM online?
404 posts
Location
St. Petersburg
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
2447 posts
Posted 04 February 2013 - 12:07 AM
Nope. Can be made in pure Lua.
997 posts
Location
Wellington, New Zealand
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?
2447 posts
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.
404 posts
Location
St. Petersburg
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.