A bit of cleaning
This commit is contained in:
parent
2fadcdefdd
commit
d8e17687e1
20
src/api.lua
20
src/api.lua
|
@ -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)
|
||||||
|
|
Ŝarĝante…
Reference in New Issue