599 posts
Location
LeLua
Posted 10 November 2015 - 04:03 PM
INI ( INITIALIZATION/CONFIG ) files for ComputerCraft
What is INI and why do I need it?
INI files are config files that stores information. For example:
[PLAYER] –This is a section–
–These are keys with values–
Name=LeDark Lua
HP=100
XP=120
MAX_XP=500
Why to use it? Because it is cool and easy.
Ok, you got me, where do I get it?
INI API pastebin:
How to use it?
Read INI:
INI_TABLE=INI.retrieve(path)
VALUE=INI_TABLE.SECTION_NAME.KEY_NAME
print(VALUE) –output: Hello, world!
Write INI:
INI_TABLE={
SECTION_NAME={
KEY_NAME="Hello, world!";
}
}
INI.write(path, INI_TABLE)
Edited on 23 December 2015 - 08:43 AM
2679 posts
Location
You will never find me, muhahahahahaha
Posted 10 November 2015 - 04:22 PM
So this is basically like a fancy version of serialize, which implements file reading/writing?
599 posts
Location
LeLua
Posted 10 November 2015 - 04:24 PM
Yeah, but INI style :)/>
EDIT: Yeah and Nope. Because I did my parser for the INI files and stuff.
Edited on 10 November 2015 - 03:30 PM
1847 posts
Location
/home/dannysmc95
Posted 21 December 2015 - 02:41 PM
Does this get multiple values on a single line? As INI files do support multiple values per line, example:
[section]
key=value1,value2,value3
2679 posts
Location
You will never find me, muhahahahahaha
Posted 21 December 2015 - 03:59 PM
Does this get multiple values on a single line? As INI files do support multiple values per line, example:
[section]
key=value1,value2,value3
A variable with multiple values?
1847 posts
Location
/home/dannysmc95
Posted 21 December 2015 - 05:34 PM
Does this get multiple values on a single line? As INI files do support multiple values per line, example:
[section]
key=value1,value2,value3
A variable with multiple values?
Pretty much what I said…
599 posts
Location
LeLua
Posted 23 December 2015 - 08:12 AM
I'll add multi values, and I didn't know that ini's support that.
1847 posts
Location
/home/dannysmc95
Posted 23 December 2015 - 08:58 AM
I'll add multi values, and I didn't know that ini's support that.
Yeah neither did I tbh, but when I was looking at the syntax, multiple values came up, so yeah, I made one, but of course it doesn't support it, and I don't really want to re-make it :D/>
599 posts
Location
LeLua
Posted 23 December 2015 - 09:46 AM
UPDATED!
Added multi value support!
Ini file:
[TEST]
testas=1,2,Hello world! STR,3
Example:
os.loadAPI("ini")
local content=ini.retrieve("test.ini")
ini.write("testas.ini", {
TEST={
testas={
123;
"Hello world!";
456;
}
}
})
print(content.TEST.testas)
for i=1, #content.TEST.testas do
print(content.TEST.testas[i])
end