Config
Парсинг и дамп ini-файлов.
Файл fba.ini
first = hi
a[] = 1
a[] = 2
a[] = true
; Это комментарий.
# И это тоже.
[extensions]
sounds=1
ttf=1
bool1 = "yes"
bool2 = "false"
bool3=no
bool4 = true
a[] = 1
a[] = 2
a[] = 3
[sound]
maxsfx.channels=16
maxmodchannels=2
stereo=1
bps=16
frequency=44100
[startup]
windowtopmost=0
ignore_include_void=
trans_3=255
trans_2=0
trans_1=255
bgcolor_3=255
bgcolor_2=255
bgcolor_1=255
socket_timeout=600
debugport=0
start-step-by-step=0
fps=30
windowsheight=480
windowswidth=640
vga=0
orientation=0
l.config.__init()
Парсит файл. Если вторым параметром передать true, то секции ini-файла будет проигнорированны.
Пример
test = l.config('fba.ini');
l.dump(test.extensions);
--[[ (table)table: 00439D00 {
[sounds] => (number)1
[bool4] => (boolean)true
[bool2] => (string)false
[ttf] => (number)1
[a] => table: 00439D00 {
[1] => (string)1
[2] => (string)2
[3] => (string)3
}
[bool3] => (boolean)false
[bool1] => (string)yes
} ]]
l.config.__tostring()
Переводит обратно в тектовый вид.
Пример
print(test);
-- или
print(tostring(test));
--[[
a[] = 1
a[] = 2
a[] = true
first = hi
[startup]
orientation = 0
bgcolor_3 = 255
start-step-by-step = 0
ignore_include_void =
windowtopmost = 0
windowswidth = 640
bgcolor_1 = 255
trans_1 = 255
trans_2 = 0
debugport = 0
socket_timeout = 600
fps = 30
windowsheight = 480
trans_3 = 255
vga = 0
bgcolor_2 = 255
[sound]
bps = 16
frequency = 44100
stereo = 1
maxmodchannels = 2
maxsfx.channels = 16
[extensions]
sounds = 1
bool4 = true
bool2 = "false"
ttf = 1
a[] = 1
a[] = 2
a[] = 3
bool3 = false
bool1 = "yes"
]]