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

ComputerCraft Registry

Started by LewisTehMinerz, 17 May 2015 - 03:19 PM
LewisTehMinerz #1
Posted 17 May 2015 - 05:19 PM

Hello! If you are reading this, I presume your looking for a ComputerCraft Registry API!

Well, your in luck! I have invented a registry API for you to replace separate configuration files and just have keys! (AKA this is some sort of configuration API, but a bit better as it hides the files ;)/> ) Let me show you how it works.
I have loaded the API as "Registry".



Registry.openReg()

This opens the registry, allowing access to the Keys table.


Registry.closeReg()

This closes the registry, wiping the Keys table.


Registry.createKey( keyName, value )

This creates a key in the registry, where keyName is the key's name and value is anything.


Registry.deleteKey( keyName )

This deletes a key in the registry, where keyName is the key's name.


Registry.getKeyAmount()

Returns the amount of keys currently inside the registry.


Registry.Keys[ keyName ]

Gets the value of the key, where keyName is the key's name.


Registry,modifyKey( keyName, value )

Changes the value of a key, where keyName is the key's name and value is the value.

All functions return true and false respectively if they succeeded or failed (except for getKeyAmount() and Keys[]).

To download, simply run:


pastebin get MRRGbq76 Registry

in shell.
Edited on 04 August 2015 - 06:41 AM
flaghacker #2
Posted 17 May 2015 - 05:22 PM
You forgot the code, and I can't tell what this does by reading your post. Is it some kind of configuration file api? If so, how can I read a key? Where does it make the config file? Is it something like the Windows registry?
LewisTehMinerz #3
Posted 17 May 2015 - 05:31 PM
Just fixed the post, added what this does and pastebin link.
minebuild02 #4
Posted 09 June 2015 - 09:08 AM
In the createKey() and deleteKey() functions, you forgot to put existance checks.
Without them, if, for example, you call

deleteKey("Local")
and this file didn't exist, your program would simply exit with an error message.
In case of createKey(), if that key has already existed, it would be overwritten.