feat: add lines to data
This commit is contained in:
parent
3687f5297f
commit
09581b436d
3 changed files with 20 additions and 4 deletions
|
@ -12,7 +12,7 @@ function BeastFile:new(folder, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BeastFile:readLines()
|
function BeastFile:readLines()
|
||||||
local lines = parseFile(self.filepath, function (line) print(line) end)
|
local lines = parseFile(self.filepath, function (line) self.datas:addLine(line) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BeastFile:prepareJson()
|
function BeastFile:prepareJson()
|
||||||
|
|
|
@ -12,7 +12,7 @@ function Data.fromLine(line)
|
||||||
name = utils.trim(datas[1])
|
name = utils.trim(datas[1])
|
||||||
for i, v in ipairs(datas) do
|
for i, v in ipairs(datas) do
|
||||||
if (i > 1) then
|
if (i > 1) then
|
||||||
table.insert(utils.trim(v))
|
table.insert(args, utils.trim(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local level = 0
|
local level = 0
|
||||||
|
@ -20,7 +20,7 @@ function Data.fromLine(line)
|
||||||
levelString = utils.trim(command[2]);
|
levelString = utils.trim(command[2]);
|
||||||
level = tonumber(levelString) or 0
|
level = tonumber(levelString) or 0
|
||||||
end
|
end
|
||||||
return Data(name, args, level)
|
return Data(name, commands.clean(args, name), level)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Data:new(name, arguments, level)
|
function Data:new(name, arguments, level)
|
||||||
|
@ -31,13 +31,14 @@ end
|
||||||
|
|
||||||
function DataList:new()
|
function DataList:new()
|
||||||
self.list = {}
|
self.list = {}
|
||||||
|
self.reducedList = {}
|
||||||
for key, value in pairs(commands.getDefaults()) do
|
for key, value in pairs(commands.getDefaults()) do
|
||||||
table.insert(self.list, Data(key, value, 0))
|
table.insert(self.list, Data(key, value, 0))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function DataList:addLine(line)
|
function DataList:addLine(line)
|
||||||
table.insert(self.list, Data.line(line))
|
table.insert(self.list, Data.fromLine(line))
|
||||||
end
|
end
|
||||||
|
|
||||||
function DataList:reduce()
|
function DataList:reduce()
|
||||||
|
|
|
@ -42,4 +42,19 @@ function functions.getDefaults()
|
||||||
return defaults
|
return defaults
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function functions.clean(args, command)
|
||||||
|
local baseCommand = commands[command]
|
||||||
|
if (baseCommand == nil) then
|
||||||
|
error("Command " .. baseCommand .. " doesn't exists")
|
||||||
|
end
|
||||||
|
if (baseCommand.args == nil or baseCommand.args == 1) then
|
||||||
|
local arg = args[1]
|
||||||
|
if (baseCommand.contentType == "number") then
|
||||||
|
arg = tonumber(arg)
|
||||||
|
end
|
||||||
|
return arg
|
||||||
|
end
|
||||||
|
return args
|
||||||
|
end
|
||||||
|
|
||||||
return functions
|
return functions
|
Loading…
Reference in a new issue