2024-08-01 23:14:47 +02:00
|
|
|
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
|
2024-08-01 23:56:04 +02:00
|
|
|
table.insert(args, utils.trim(v))
|
2024-08-01 23:14:47 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
local level = 0
|
|
|
|
if (command[2] ~= nil) then
|
|
|
|
levelString = utils.trim(command[2]);
|
|
|
|
level = tonumber(levelString) or 0
|
|
|
|
end
|
2024-08-01 23:56:04 +02:00
|
|
|
return Data(name, commands.clean(args, name), level)
|
2024-08-01 23:14:47 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Data:new(name, arguments, level)
|
|
|
|
self.name = name
|
|
|
|
self.arguments = arguments
|
|
|
|
self.level = level
|
|
|
|
end
|
|
|
|
|
|
|
|
function DataList:new()
|
|
|
|
self.list = {}
|
2024-08-01 23:56:04 +02:00
|
|
|
self.reducedList = {}
|
2024-08-01 23:14:47 +02:00
|
|
|
for key, value in pairs(commands.getDefaults()) do
|
|
|
|
table.insert(self.list, Data(key, value, 0))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function DataList:addLine(line)
|
2024-08-01 23:56:04 +02:00
|
|
|
table.insert(self.list, Data.fromLine(line))
|
2024-08-01 23:14:47 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function DataList:reduce()
|
|
|
|
--TODO
|
|
|
|
end
|
|
|
|
|
|
|
|
function DataList:prepareJson()
|
|
|
|
return self.list
|
|
|
|
end
|
|
|
|
|
|
|
|
return DataList
|