Posted 23 December 2015 - 08:27 PM
This is old. Get the newer versions here.
libCFG is the configuration API of AdmiOS RW.
Installation: execute
External Modifier:
Like the demo, it also assumes you have libCFG in the same folder. But it will use the already-loaded libCFG if it's running in AdmiOS (New version with the variable is coming very soon)
How to use:
1. load libCFG like so:
3. Make a cool program
4. Profit
Methods:
- readConfig(file)
- readConfigRaw(string)
The returned tables can be used like:
- writeConfig(file, table)
Table should be formatted like this:
Config style:
An example config is shown below:
Note: Writing to a config will remove all the comments. If you know how to preserve them, just comment it here and i will probably use it.
libCFG is the configuration API of AdmiOS RW.
Installation: execute
pastebin get icmFaCNc libCFG
Demo: pastebin get q13TtRKt demo
The demo assumes you have libCFG in the same folder as the demoExternal Modifier:
pastebin get YMVBPquM aconf
The external modifier is a program that can edit/delete and create keys in libCFG files.Like the demo, it also assumes you have libCFG in the same folder. But it will use the already-loaded libCFG if it's running in AdmiOS (New version with the variable is coming very soon)
How to use:
1. load libCFG like so:
os.loadAPI("libCFG")
2. Use the methods below to read/write config files.3. Make a cool program
4. Profit
Methods:
- readConfig(file)
libCFG.readConfig(file)
Reads the contents of the file and returns a table of the configuration keys/values.- readConfigRaw(string)
libCFG.readConfig(string)
Reads the contents of the string and returns a table of the configuration keys/values.The returned tables can be used like:
value = table["key"]
- writeConfig(file, table)
libCFG.writeConfig(file, table)
Writes the contents of the table to file.Table should be formatted like this:
table = {
key = "value"
}
Config style:
An example config is shown below:
#libCFG Example config
#lines starting with hashtags are comments
#they will be ignored and will NOT be rewritten when you use writeConfig()
#comments CANNOT use colons
#this comment: will not work
#Here is an example config entry
key: value
#Here is an example config that could be used in a program
saveDirectory: /program/saves
saveInterval: 10
#these entries will result as
# table["saveDirectory"] = "/program/saves"
# table["saveInterval"] = 10
Note: Writing to a config will remove all the comments. If you know how to preserve them, just comment it here and i will probably use it.
Edited on 26 September 2016 - 06:42 PM