A bit of cleaning

This commit is contained in:
Jean-Patrick Guerrero 2021-12-25 17:23:49 +01:00
parent 2fadcdefdd
commit d8e17687e1

View File

@ -85,26 +85,24 @@ function i3.register_craft(def)
end end
else else
local items = copy(def.items) local items = copy(def.items)
local len = #items local lines = {}
def.items = {} def.items = {}
for i = 1, len do for i = 1, #items do
local rlen = #split(items[i], ",") lines[i] = split(items[i], ",", true)
if rlen > width then if #lines[i] > width then
width = rlen width = #lines[i]
end end
end end
for i = 1, len do for i = 1, #items do
while #split(items[i], ",", true) < width do while #lines[i] < width do
items[i] = fmt("%s,", items[i]) insert(lines[i], items[i])
end end
end end
for _, line in ipairs(items) do for _, line in ipairs(lines) do
line = split(line, ",", true)
for _, v in ipairs(line) do for _, v in ipairs(line) do
c++ c++
def.items[c] = clean_name(v) def.items[c] = clean_name(v)