Модуль: Infobox tmp: различия между версиями 🔗
Материал из VEDA Wiki
Sphynkx (обсуждение | вклад) Нет описания правки Метка: отменено |
Sphynkx (обсуждение | вклад) Нет описания правки Метка: ручная отмена |
||
Строка 39: | Строка 39: | ||
end -- if l[2] | end -- if l[2] | ||
if | if l[3] == nil or l[3] == '' or l[3] == ' ' then | ||
field3 = '' | field3 = '' | ||
count = count + 1 | count = count + 1 |
Версия от 20:17, 2 октября 2024
Для документации этого модуля может быть создана страница Модуль:Infobox tmp/doc
local p = {} -- p stands for package
function p.event_members( frame )
local name = frame.args[1]
local count = 0 -- computes overall amount of members as 1 per person or as number in 'Количество' field
local t = {[=[<table border=0>
<tr><td colspan=2>
<div {{DivWrapOpts}}>[[Category:WrapBlock]]
<table border=0 width=100%><tr><td colspan="2" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold; text-align: center;">Участники</td></tr></table>
<div class="mw-collapsible-content">
<table border=0>
]=]}
-- continue if line is "empty" (namely is "!!!;") see: https://forum.defold.com/t/any-replace-for-continue-statement-in-lua-loops/65554/2
for i in string.gmatch(name, "[^;]+") do repeat
if #i <6 then
do break end
end
local field2 = ''
local field3 = ''
table.insert(t, [=[<tr>
<td colspan="2" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold; text-align: center;">Участник</td>
</tr>]=])
local l = {}
for k in string.gmatch(i, "[^!]+") do
table.insert(l, k:match( "^%s*(.-)%s*$" ))
end
if l[2] == nil or l[2] == '' or l[2] == ' ' then
field2 = ''
else
field2 = [=[<tr>
<td colspan="2"><hr></td>
</tr><tr>
<td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Категория:</td>
<td>]=] .. l[2] .. '</td></tr>'
end -- if l[2]
if l[3] == nil or l[3] == '' or l[3] == ' ' then
field3 = ''
count = count + 1
else
field3 = [=[<tr>
<td colspan="2"><hr></td>
</tr><tr>
<td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Количество:</td>
<td>]=] .. l[3] .. '</td></tr>'
count = count + l[3]
end -- if l[3]
table.insert(t, [=[<tr>
<td colspan="2"><hr></td>
</tr><tr>
<td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Имя:</td>
<td>[[]=] .. l[1] .. ']]</td></tr>' .. [=[[[Category:]=] .. l[1] .. [=[]]]=]
.. field2 .. field3)
until true end -- 'for i' cycle
table.insert(t, [=[</table>
</div></div>
</td></tr>
<tr>
<td align="left" width="10%" bgcolor="#{{#dplvar:boxbgcolor}}" style="font-weight: bold;">Общее число:</td>
<td>не менее
]=] .. count .. '</td></tr>')
return table.concat(t, "")
end
return p