Jump to content




NVRAM


  • You cannot reply to this topic
28 replies to this topic

#1 tesla1889

  • Members
  • 351 posts
  • LocationSt. 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


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 30 January 2013 - 03:15 PM

You could easily write an API to do this with a special file.

#3 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 30 January 2013 - 03:18 PM

the point is to do this without a file

#4 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 30 January 2013 - 03:21 PM

View Posttesla1889, on 30 January 2013 - 03:18 PM, said:

the point is to do this without a file

Why? You know files can be hidden.

#5 ChunLing

  • Members
  • 2,027 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).

#6 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 30 January 2013 - 03:37 PM

View PostChunLing, on 30 January 2013 - 03:23 PM, said:

--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

#7 ChunLing

  • Members
  • 2,027 posts

Posted 30 January 2013 - 05:00 PM

...

What do you mean, it's a read-only file?

#8 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 30 January 2013 - 05:44 PM

minecraft/

saves/

your_saved_world/

computer/

nvram/ *

0

1

2


* this is where it probably should be saved

each file in the nvram folder would correspond to the computer with the same id number

#9 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, 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).

#10 tesla1889

  • Members
  • 351 posts
  • LocationSt. 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

#11 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 30 January 2013 - 06:49 PM

View Posttesla1889, on 30 January 2013 - 06:44 PM, said:

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.

#12 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 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.

#13 tesla1889

  • Members
  • 351 posts
  • LocationSt. 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

#14 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 30 January 2013 - 08:51 PM

View Posttesla1889, on 30 January 2013 - 07:18 PM, said:

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?

#15 tesla1889

  • Members
  • 351 posts
  • LocationSt. 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

#16 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 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.

#17 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 01 February 2013 - 12:52 PM

View Posttesla1889, on 31 January 2013 - 07:30 PM, said:

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.

#18 ChunLing

  • Members
  • 2,027 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.

#19 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 01 February 2013 - 04:49 PM

View PostChunLing, on 01 February 2013 - 04:48 PM, said:

More to the point, there is no reason that each operating system couldn't use its own hidden file for this purpose.

Agreed.

#20 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 02 February 2013 - 06:42 PM

View PostLyqyd, on 01 February 2013 - 04:53 AM, said:

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?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users