(Новая страница: «local p = {}; function p.list(f) local args = f; if f == mw.getCurrentFrame() then args = f:getParent().args; else f = mw.getCurrentFrame(); end; loca…») |
мНет описания правки |
||
Строка 16: | Строка 16: | ||
local temp3 = "_(ThaumCraft).png]] <span class=\"explain tooltip\" title=\""; |
local temp3 = "_(ThaumCraft).png]] <span class=\"explain tooltip\" title=\""; |
||
− | local |
+ | local notDelimeter = function(arg) |
return (arg ~= '-\n') and (arg ~= '') and (arg ~= '+'); |
return (arg ~= '-\n') and (arg ~= '') and (arg ~= '+'); |
||
end; |
end; |
||
Строка 35: | Строка 35: | ||
local text = args[i] |
local text = args[i] |
||
local m = 1; |
local m = 1; |
||
− | if |
+ | if notDelimeter(args[i + 1]) then |
m = 2; |
m = 2; |
||
table.insert(out, slot({args[i + 1]})); |
table.insert(out, slot({args[i + 1]})); |
||
− | if |
+ | if notDelimeter(args[i + 2]) then |
m = 3; |
m = 3; |
||
table.insert(out, slot({args[i + 2]})); |
table.insert(out, slot({args[i + 2]})); |
||
− | if |
+ | if notDelimeter(args[i + 3]) then |
m = 4; |
m = 4; |
||
table.insert(out, slot({args[i + 3]})); |
table.insert(out, slot({args[i + 3]})); |
||
− | if |
+ | if notDelimeter(args[i + 4]) then |
m = 5; |
m = 5; |
||
table.insert(out, slot({args[i + 4]})); |
table.insert(out, slot({args[i + 4]})); |
||
− | if |
+ | if notDelimeter(args[i + 5]) then |
m = 6; |
m = 6; |
||
table.insert(out, slot({args[i + 5]})); |
table.insert(out, slot({args[i + 5]})); |
Версия от 13:05, 30 августа 2018
local p = {};
function p.list(f)
local args = f;
if f == mw.getCurrentFrame() then
args = f:getParent().args;
else
f = mw.getCurrentFrame();
end;
local slot = require('Модуль:Инвентарный слот').slot;
local out = {"{|class=\"invslot-plain\""};
local temp1 = "\n|valign=\"top\"|\n<span id=\"";
local temp2 = "\">\n{|class=\"wikitable collapsible collapsed\" style=\"margin: 0px\"\n!width=250px style=\"text-align: left\"|[[Файл:Aspect_";
local temp3 = "_(ThaumCraft).png]] <span class=\"explain tooltip\" title=\"";
local notDelimeter = function(arg)
return (arg ~= '-\n') and (arg ~= '') and (arg ~= '+');
end;
local i = 1;
local n = 0;
while args[i] ~= 'end' do
-- добавляет название блока
table.insert(out, temp1 .. args[i] .. temp2 .. args[i] .. temp3 .. args[i + 1] .. '\">' .. args[i] .. '</span>')
i = i + 3;
while args[i] ~= '-\n' do
table.insert(out, '\n|-\n|' .. args[i] .. '×');
i = i + 1;
-- добавляет иконки
table.insert(out, slot({args[i]}));
local text = args[i]
local m = 1;
if notDelimeter(args[i + 1]) then
m = 2;
table.insert(out, slot({args[i + 1]}));
if notDelimeter(args[i + 2]) then
m = 3;
table.insert(out, slot({args[i + 2]}));
if notDelimeter(args[i + 3]) then
m = 4;
table.insert(out, slot({args[i + 3]}));
if notDelimeter(args[i + 4]) then
m = 5;
table.insert(out, slot({args[i + 4]}));
if notDelimeter(args[i + 5]) then
m = 6;
table.insert(out, slot({args[i + 5]}));
end;
end;
end;
end;
end;
-- добавляет текст
if args[i + m] == '' then
i = i + m + 1;
text = args[i];
else
local at, r = string.find(text, ':');
if at ~= nil then
if string.sub(text, 1, at - 1) == 'thaum' then
-- относительная ссылка
text = '[[../' .. string.sub(text, at + 1) .. '/]]';
end;
else
text = '[[' .. text .. ']]';
end;
if args[i + 1] == '+' then
i = i + 2;
text = text .. ' ' .. args[i];
end;
end;
i = i + 2;
table.insert(out, ' ' .. text);
end;
table.insert(out, '\n|}');
i = i + 1;
n = n + 1;
if n == 3 then
table.insert(out, '\n|-\n');
n = 0;
end;
end;
table.insert(out, '\n|}');
return table.concat(out);
end;
return p;