Изменения

Модуль:Сетка/Структура

1699 байтов добавлено, 08:40, 3 августа 2016
Новая страница: «p = {} p.structure = function(f) local args = f.args or f if f == mw.getCurrentFrame() and args[1] == nil then args = f:getParent().args end args = require…»
p = {}

p.structure = function(f)
local args = f.args or f
if f == mw.getCurrentFrame() and args[1] == nil then
args = f:getParent().args
end
args = require("Модуль:ProcessArgs").norm(args)

local i = 0
for index, arg in ipairs(args) do
i = i + 1
end

local result = {}
table.insert(result, '<table cellpadding="2" cellspacing="0" style="line-height: 36px; padding-right: 20px; padding-bottom: 20px">')
local border = 0

local invSlot = require("Модуль:Инвентарный слот").slot

for index, arg in ipairs(args) do
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слой ' .. i .. '</td><td>')
for i2 = 1, mw.ustring.len(arg) do
local argChar = mw.ustring.sub(arg, i2, i2)
if argChar == ',' then
table.insert(result, '</td><td>')
else
if argChar == '^' then
border = border + 1
else
if argChar ~= '-' then
table.insert(result, '<span style="position: absolute; margin-left: -20px; margin-top: 10px; z-index: -1">[[Файл:Сетка изометрия.png|link=]]</span>')
end
local slotArgs = {}
if args["M" .. argChar] then
slotArgs["мод"] = args["Мод"]
end
slotArgs[1] = (args["M" .. argChar] or '') .. (args[argChar] or '')
slotArgs["класс"] = "invslot-plain"
if border ~= 0 then
slotArgs["стиль"] = "outline: 2px solid " .. ({"red", "blue", "green"})[border]
end
table.insert(result, invSlot(slotArgs))
border = 0
table.insert(result, "<br>")
end
end
end
table.insert(result, "</td></tr>\n")
i = i - 1
end
table.insert(result, "</table>")
return table.concat(result)
end

return p