51 lines
1.1 KiB
Lua
51 lines
1.1 KiB
Lua
|
local Data = Object:extend()
|
||
|
local DataList = Object:extend()
|
||
|
|
||
|
function Data.fromLine(line)
|
||
|
line = utils.removeComment(line)
|
||
|
if (#line == 0) then
|
||
|
return nil
|
||
|
end
|
||
|
local command = utils.split(line, "|")
|
||
|
local datas = utils.split(utils.trim(command[1]), ";")
|
||
|
local args = {}
|
||
|
name = utils.trim(datas[1])
|
||
|
for i, v in ipairs(datas) do
|
||
|
if (i > 1) then
|
||
|
table.insert(utils.trim(v))
|
||
|
end
|
||
|
end
|
||
|
local level = 0
|
||
|
if (command[2] ~= nil) then
|
||
|
levelString = utils.trim(command[2]);
|
||
|
level = tonumber(levelString) or 0
|
||
|
end
|
||
|
return Data(name, args, level)
|
||
|
end
|
||
|
|
||
|
function Data:new(name, arguments, level)
|
||
|
self.name = name
|
||
|
self.arguments = arguments
|
||
|
self.level = level
|
||
|
end
|
||
|
|
||
|
function DataList:new()
|
||
|
self.list = {}
|
||
|
for key, value in pairs(commands.getDefaults()) do
|
||
|
table.insert(self.list, Data(key, value, 0))
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function DataList:addLine(line)
|
||
|
table.insert(self.list, Data.line(line))
|
||
|
end
|
||
|
|
||
|
function DataList:reduce()
|
||
|
--TODO
|
||
|
end
|
||
|
|
||
|
function DataList:prepareJson()
|
||
|
return self.list
|
||
|
end
|
||
|
|
||
|
return DataList
|