Нет описания правки |
мНет описания правки |
||
(не показано 30 промежуточных версий 3 участников) | |||
Строка 8: | Строка 8: | ||
args = require("Модуль:ProcessArgs").norm(args) |
args = require("Модуль:ProcessArgs").norm(args) |
||
− | local i = |
+ | local i = #args |
+ | |||
− | for index, arg in ipairs(args) do |
||
+ | local dub = {} |
||
⚫ | |||
+ | if args.dub~=nil then |
||
+ | for v in mw.text.gsplit( args.dub or '', '%s*;%s*' ) do |
||
⚫ | |||
+ | dub[tonumber(mw.text.split( v, '%s*,%s*' )[1])] = h |
||
⚫ | |||
⚫ | |||
end |
end |
||
+ | |||
− | |||
local result = {} |
local result = {} |
||
table.insert(result, '<table cellpadding="2" cellspacing="0" style="line-height: 36px; padding-right: 20px; padding-bottom: 20px">') |
table.insert(result, '<table cellpadding="2" cellspacing="0" style="line-height: 36px; padding-right: 20px; padding-bottom: 20px">') |
||
Строка 20: | Строка 26: | ||
for index, arg in ipairs(args) do |
for index, arg in ipairs(args) do |
||
+ | local k = 1 |
||
⚫ | |||
+ | if dub[#args-index+1] ~= nil then |
||
− | |||
+ | k = dub[#args-index+1] |
||
⚫ | |||
+ | end |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слои ' .. i - k + 1 .. '-' .. i .. '</td><td>') |
||
+ | end |
||
+ | local sloy = {} |
||
+ | sloy = mw.text.split(arg,',') |
||
local mass = {} |
local mass = {} |
||
local massb = {} |
local massb = {} |
||
− | local |
+ | local maxw = #sloy |
for row = 1, #sloy do |
for row = 1, #sloy do |
||
− | + | local line = sloy[row] |
|
− | + | maxw = math.max(maxw, mw.ustring.len(mw.ustring.gsub(line, '%^', '')) ) |
|
mass[row] = {} |
mass[row] = {} |
||
massb[row] = {} |
massb[row] = {} |
||
Строка 36: | Строка 50: | ||
border = border + 1 |
border = border + 1 |
||
else |
else |
||
− | mass[row] |
+ | table.insert(mass[row],argChar) |
if border ~= 0 then |
if border ~= 0 then |
||
− | massb[row][ |
+ | massb[row][#mass[row]] = border |
border = 0 |
border = 0 |
||
end |
end |
||
Строка 45: | Строка 59: | ||
end |
end |
||
+ | for i2 = 1, maxw + #sloy - 1 do |
||
− | |||
− | for |
+ | for n = math.max(1,i2+1-maxw), math.min(i2,maxw) do |
⚫ | |||
− | local argChar = mw.ustring.sub(arg, i2, i2) |
||
− | + | argChar = '-' |
|
+ | elseif mass[n][i2+1-n] == nil then |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | border = border + 1 |
||
else |
else |
||
− | + | argChar = mass[n][i2+1-n] |
|
+ | end |
||
⚫ | |||
+ | local slotArgs = {} |
||
⚫ | |||
− | + | if (argChar ~= '-') then |
|
⚫ | |||
− | if |
+ | if (argChar ~= '_') then |
slotArgs["мод"] = args["Мод"] |
slotArgs["мод"] = args["Мод"] |
||
⚫ | |||
end |
end |
||
+ | else |
||
⚫ | |||
− | slotArgs[ |
+ | slotArgs[1] = '' |
+ | end |
||
⚫ | |||
− | + | slotArgs["класс"] = "invslot-plain" |
|
+ | if massb[n] ~= nil then |
||
+ | if massb[n][i2+1-n] ~= nil then |
||
+ | slotArgs["стиль"] = "position: relative; z-index:2; outline: 2px solid " .. ({"red", "blue", "green"})[massb[n][i2+1-n]] |
||
+ | else |
||
+ | slotArgs["стиль"] = "position: relative; z-index:2;" |
||
end |
end |
||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
end |
end |
||
table.insert(result, "</td></tr>\n") |
table.insert(result, "</td></tr>\n") |
||
− | i = i - |
+ | i = i - k |
end |
end |
||
table.insert(result, "</table>") |
table.insert(result, "</table>") |
Текущая версия от 10:34, 6 июня 2021
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 = #args
local dub = {}
if args.dub~=nil then
for v in mw.text.gsplit( args.dub or '', '%s*;%s*' ) do
h = mw.text.split( v, '%s*,%s*' )[2]
dub[tonumber(mw.text.split( v, '%s*,%s*' )[1])] = h
i = i + h - 1
end
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
local k = 1
if dub[#args-index+1] ~= nil then
k = dub[#args-index+1]
end
if k == 1 then
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слой ' .. i .. '</td><td>')
else
table.insert(result, '<tr><td></td></tr><tr><td style="padding-right: 10px">Слои ' .. i - k + 1 .. '-' .. i .. '</td><td>')
end
local sloy = {}
sloy = mw.text.split(arg,',')
local mass = {}
local massb = {}
local maxw = #sloy
for row = 1, #sloy do
local line = sloy[row]
maxw = math.max(maxw, mw.ustring.len(mw.ustring.gsub(line, '%^', '')) )
mass[row] = {}
massb[row] = {}
for i2 = 1, mw.ustring.len(line) do
local argChar = mw.ustring.sub(line, i2, i2)
if argChar == '^' then
border = border + 1
else
table.insert(mass[row],argChar)
if border ~= 0 then
massb[row][#mass[row]] = border
border = 0
end
end
end
end
for i2 = 1, maxw + #sloy - 1 do
for n = math.max(1,i2+1-maxw), math.min(i2,maxw) do
if mass[n] == nil then
argChar = '-'
elseif mass[n][i2+1-n] == nil then
argChar = '-'
else
argChar = mass[n][i2+1-n]
end
local slotArgs = {}
if (argChar ~= '-') then
table.insert(result, '<span class="isometry" style="position: absolute; margin-left: -20px; margin-top: 10px; z-index: 1">[[Файл:Сетка изометрия.png|link=]]</span>')
if (argChar ~= '_') then
slotArgs["мод"] = args["Мод"]
slotArgs[1] = (args[argChar] or '')
end
else
slotArgs[1] = ''
end
slotArgs["класс"] = "invslot-plain"
if massb[n] ~= nil then
if massb[n][i2+1-n] ~= nil then
slotArgs["стиль"] = "position: relative; z-index:2; outline: 2px solid " .. ({"red", "blue", "green"})[massb[n][i2+1-n]]
else
slotArgs["стиль"] = "position: relative; z-index:2;"
end
end
table.insert(result, invSlot(slotArgs))
table.insert(result, "<br>")
end
table.insert(result, '</td><td>')
end
table.insert(result, "</td></tr>\n")
i = i - k
end
table.insert(result, "</table>")
return table.concat(result)
end
return p