Minecraft Wiki
Регистрация
Нет описания правки
Нет описания правки
 
(не показано 66 промежуточных версий 9 участников)
Строка 1: Строка 1:
 
local p = {}
 
local p = {}
  +
p.row = function( f )
 
  +
local breakingTimeHeader;
local args = require( [[Модуль:ProcessArgs]] ).norm()
 
  +
local function getBreakingTimeHeader( f )
 
  +
if breakingTimeHeader == nil then
local getDplVar = function( var )
 
  +
breakingTimeHeader = 'Время [[Добывание|разрушения]]' .. f:preprocess( '<ref group="FN" name="breakingtimenote">Время для незачарованных инструментов, используемых игроком без наложенных эффектов, в секундах. Для большей информации см. [[Добывание#Скорость|Добывание § Скорость]].</ref>' )
local val = f:callParserFunction( '#dplvar', 'breaking ' .. var )
 
if val == '' then
+
end
  +
return breakingTimeHeader
val = false
 
end
+
end
  +
return val
 
  +
function p.row( f )
end
 
  +
local args = require( [[Модуль:ProcessArgs]] ).norm()
local dplVars = {}
 
local setDplVar = function( var, val )
+
local sprite = require( [[Модуль:Спрайт]] )
  +
table.insert( dplVars, 'breaking ' .. var )
 
  +
local function getDplVar( var )
table.insert( dplVars, val or '1' )
 
  +
local val = f:callParserFunction( '#dplvar', 'breaking ' .. var )
  +
if val == '' then
  +
val = false
  +
end
  +
return val
  +
end
  +
local dplVars = {}
  +
local function setDplVar( var, val )
  +
table.insert( dplVars, 'breaking ' .. var )
  +
table.insert( dplVars, val or '1' )
  +
end
  +
  +
local rows = {}
  +
local tableParts = {}
  +
local categories = {}
  +
  +
local horizontal
  +
args[1] = args[1] or '' -- чтобы не переделывать весь модуль, ранее считавший, что тут строка
  +
  +
-- Подставляет название страницы, если параметр args[1] не указан.
  +
if (args[1] == '') or (args[1] == nil) then
  +
args[1] = mw.title.getCurrentTitle().text
  +
args["встолбик"] = 1
 
end
 
end
 
 
  +
if args["встолбик"] or args[1]:match( ';' ) then
local breakingTimeHeader = 'Время [[Добыча|разрушения]]' .. f:preprocess( '<ref group="note">Время для незачарованных инструментов в секундах.</ref>' )
 
  +
horizontal = true
 
  +
end
local rows = {}
 
local tableParts = {}
+
local showTool = true
local categories = {}
+
local showShears = true
  +
local showSword = true
 
  +
local header, sortable, simple
local horizontal
 
if args["встолбик"] or args[1]:match( ';' ) then
+
if horizontal or not getDplVar( 'header' ) then
  +
if args["скрытьинструмент"] or horizontal and ( not args[2] or args[2]:lower() == 'any' or args[2]:lower() == 'none' ) then
horizontal = true
 
  +
showTool = false
end
 
  +
setDplVar( 'hidetool' )
local showTool = true
 
  +
breakingTimeHeader = 'Время [[Добывание|разрушения]]'
local showShears = true
 
  +
end
local showSword = true
 
  +
if args["скрытьножницы"] or horizontal and not args["ножницы"] then
local header, sortable, simple
 
  +
showShears = false
if horizontal or not getDplVar( 'header' ) then
 
  +
setDplVar( 'hideshears' )
if args["скрытьинструмент"] or horizontal and ( not args[2] or args[2]:lower() == 'any' or args[2]:lower() == 'нет' ) then
 
  +
end
showTool = false
 
  +
if args["скрытьмеч"] or horizontal and not args["меч"] then
setDplVar( 'hidetool' )
 
  +
showSword = false
end
 
  +
setDplVar( 'hidesword' )
if args["скрытьножницы"] or horizontal and not args["ножницы"] then
 
  +
end
showShears = false
 
  +
setDplVar( 'hideshears' )
 
  +
sortable = not horizontal and args["сортировка"]
end
 
  +
if sortable then
if args["скрытьмеч"] or horizontal and not args["меч"] then
 
  +
setDplVar( 'sortable' )
showSword = false
 
  +
end
setDplVar( 'hidesword' )
 
  +
simple = args["простой"]
end
 
  +
if simple and not horizontal then
 
  +
setDplVar( 'simple' )
sortable = not horizontal and args["сортировка"]
 
  +
end
if sortable then
 
  +
setDplVar( 'sortable' )
 
  +
local tableClasses = { 'wikitable' }
end
 
  +
if sortable then
simple = args["простой"]
 
  +
table.insert( tableClasses, 'sortable' )
if simple and not horizontal then
 
  +
end
setDplVar( 'simple' )
 
  +
table.insert( rows, ' {| class="' .. table.concat( tableClasses, ' ' ) .. '" style="text-align:center"' )
end
 
  +
 
local tableClasses = { 'wikitable' }
+
local sortType = ''
if sortable then
+
if sortable then
  +
sortType = 'data-sort-type="number"'
table.insert( tableClasses, 'sortable' )
 
end
+
end
  +
local rowspan = ''
table.insert( rows, ' {| class="' .. table.concat( tableClasses, ' ' ) .. '" style="text-align:center"' )
 
  +
if not horizontal then
 
  +
rowspan = 'rowspan="2" '
local sortType = ''
 
  +
end
if sortable then
 
  +
header = {
sortType = 'data-sort-type="number"'
 
  +
'! ' .. rowspan .. ' | Блок'
end
 
  +
}
local rowspan = ''
 
  +
if not horizontal then
 
  +
if not simple then
rowspan = 'rowspan="2" '
 
  +
table.insert( header, '! ' .. rowspan .. sortType .. ' | Прочность' )
end
 
  +
if showTool then
header = {
 
'! ' .. rowspan .. ' | Блок'
+
table.insert( header, '! ' .. rowspan .. ' | Инструмент' )
  +
end
}
 
  +
end
 
  +
if not simple then
 
  +
local toolColumns = {}
table.insert( header, '! ' .. rowspan .. sortType .. ' | Прочность' )
 
if showTool then
+
if showTool then
  +
local firstTool = mw.text.trim( simple and 'Инструмент' or args[2] or 'Любой' ):gsub( '^%l', string.upper )
table.insert( header, '! ' .. rowspan .. ' | Инструмент' )
 
  +
firstTool = mw.text.split( firstTool, ';' )[1]
end
 
  +
if firstTool == 'Кирка' or firstTool == 'Лопата' or firstTool == 'Мотыга' then
end
 
  +
toolColumns = { 'Деревянная', 'Каменная', 'Железная', 'Алмазная', 'Незеритовая', 'Золотая' }
 
local toolColumns = {}
 
if showTool then
 
local firsttool = mw.text.trim( simple and 'Инструмент' or args[2] or 'Любое' ):gsub( '^%l', string.upper )
 
firsttool = mw.text.split( firsttool, ';' )[1]
 
if firsttool == 'Кирка' or firsttool == 'Лопата' then
 
toolColumns = { 'Деревянная', 'Каменная', 'Железная', 'Алмазная', 'Золотая' }
 
 
else
 
else
toolColumns = { 'Деревянный', 'Каменный', 'Железный', 'Алмазный', 'Золотой' }
+
toolColumns = { 'Деревянный', 'Каменный', 'Железный', 'Алмазный', 'Незеритовый', 'Золотой' }
 
end
 
end
end
+
end
  +
table.insert( toolColumns, 1, 'По умолчанию' )
table.insert(
 
  +
toolColumns, 1,
 
  +
if not simple then
'<abbr title="Сюда также относятся варианты, когда игрок использует неподходящие инструменты или предметы, не являющиеся инструментами.">Рука</abbr>'
 
  +
if showShears then
)
 
  +
table.insert( toolColumns, 'Ножницы' )
if not simple then
 
  +
end
if showShears then
 
  +
if showSword then
table.insert( toolColumns, 'Ножницы' )
 
  +
table.insert( toolColumns, 'Меч' )
end
 
  +
end
if showSword then
 
  +
end
table.insert( toolColumns, 'Меч' )
 
  +
end
 
  +
if not horizontal then
end
 
  +
table.insert( header, '! colspan="' .. #toolColumns .. '" |' .. getBreakingTimeHeader( f ) )
 
  +
table.insert( header, '|-' )
if not horizontal then
 
  +
end
table.insert( header, '! colspan="' .. #toolColumns .. '" |' .. breakingTimeHeader )
 
  +
table.insert( header, '|-' )
 
  +
local toolSprites = {
end
 
  +
["Деревянный"] = {'Спрайт/Блок', 'дубовые-доски' },
 
  +
["Деревянная"] = {'Спрайт/Блок', 'дубовые-доски' },
for _, tool in ipairs( toolColumns ) do
 
  +
["Каменный"] = { 'Спрайт/Блок', 'булыжник' },
table.insert( header, '! ' .. sortType .. ' | ' .. tool )
 
  +
["Каменная"] = { 'Спрайт/Блок', 'булыжник' },
end
 
  +
["Железный"] = { 'Спрайт/Предмет', 'железный-слиток' },
 
  +
["Железная"] = { 'Спрайт/Предмет', 'железный-слиток' },
if not horizontal then
 
  +
["Алмазный"] = { 'Спрайт/Предмет', 'алмаз' },
header = table.concat( header, '\n' )
 
  +
["Алмазная"] = { 'Спрайт/Предмет', 'алмаз' },
setDplVar( 'header', header )
 
  +
["Незеритовый"] = { 'Спрайт/Предмет', 'незеритовый-слиток' },
end
 
  +
["Незеритовая"] = { 'Спрайт/Предмет', 'незеритовый-слиток' },
table.insert( tableParts, header )
 
  +
["Золотой"] = { 'Спрайт/Предмет', 'золотой-слиток' },
else
 
  +
["Золотая"] = { 'Спрайт/Предмет', 'золотой-слиток' },
showTool = not getDplVar( 'hidetool' )
 
  +
["Ножницы"] = { 'Спрайт/Предмет', 'ножницы' },
showShears = not getDplVar( 'hideshears' )
 
  +
["Меч"] = { 'Спрайт/Предмет', 'деревянный-меч' }
showSword = not getDplVar( 'hidesword' )
 
  +
}
sortable = getDplVar( 'sortable' )
 
  +
for _, tool in ipairs( toolColumns ) do
simple = getDplVar( 'simple' )
 
  +
if toolSprites[tool] then
end
 
  +
local image, spriteCat = sprite.sprite{
 
  +
["данные"] = toolSprites[tool][1],
local sprite = require( [[Модуль:Спрайт]] )
 
  +
toolSprites[tool][2],
local hardness = require( [[Модуль:Значения блоков]] ).value
 
  +
["текст"] = tool
 
  +
}
local fillCells = function( cellsTable, text, num )
 
  +
table.insert( header, '! style="text-align:left" ' .. sortType .. ' | ' .. image )
for i = 1, num do
 
table.insert( cellsTable, text )
+
table.insert( categories, spriteCat )
  +
else
end
 
  +
table.insert( header, '! ' .. sortType .. ' | ' .. tool )
end
 
  +
end
local materialGrade = {
 
  +
end
["Любая"] = 0, ["Любой"] = 0, ["Любое"] = 0,
 
  +
["Деревянная"] = 1, ["Деревянный"] = 1,
 
  +
if not horizontal then
["Золотая"] = 1, ["Золотой"] = 1,
 
  +
header = table.concat( header, '\n' )
["Каменная"] = 2, ["Каменный"] = 2,
 
  +
setDplVar( 'header', header )
["Железная"] = 3, ["Железный"] = 3,
 
  +
end
["Алмазная"] = 4, ["Алмазный"] = 4,
 
  +
table.insert( tableParts, header )
["Нет"] = 5
 
  +
else
}
 
  +
showTool = not getDplVar( 'hidetool' )
local materialSpeed = {
 
  +
showShears = not getDplVar( 'hideshears' )
["Нет"] = 1,
 
  +
showSword = not getDplVar( 'hidesword' )
["Любая"] = 1, ["Любой"] = 1, ["Любое"] = 1,
 
  +
sortable = getDplVar( 'sortable' )
["Деревянная"] = 2, ["Деревянный"] = 2,
 
  +
simple = getDplVar( 'simple' )
["Каменная"] = 4, ["Каменный"] = 4,
 
  +
end
["Железная"] = 6, ["Железный"] = 6,
 
  +
["Алмазная"] = 8, ["Алмазный"] = 8,
 
  +
local hardness = require( [[Модуль:Значения блоков]] ).value
["Золотая"] = 12, ["Золотой"] = 12
 
  +
}
 
local insertBlock = function( blockArgs )
+
local function fillCells( cellsTable, text, num )
  +
for i = 1, num do
local cells = {}
 
  +
table.insert( cellsTable, text )
local blocks = mw.text.split( blockArgs[1], '%s*,%s*' )
 
  +
end
local hardnessVal = tonumber( hardness{ blocks[1], ["тип"] = 'прочности' } )
 
  +
end
if not hardnessVal then
 
  +
local materialGrade = {
hardnessVal = '?'
 
  +
["Любой"] = 0, ["Любая"] = 0,
end
 
  +
["Деревянный"] = 1, ["Деревянная"] = 1,
local unbreakable
 
  +
["Золотой"] = 1, ["Золотая"] = 1,
if hardnessVal == -1 or blockArgs.liquid then
 
  +
["Каменный"] = 2, ["Каменная"] = 2,
unbreakable = true
 
  +
["Железный"] = 3, ["Железная"] = 3,
end
 
  +
["Алмазный"] = 4, ["Алмазная"] = 4,
 
  +
["Незеритовый"] = 5, ["Незеритовая"] = 5,
local blockSprites = {}
 
  +
["Нет"] = 6
local links = mw.text.split( blockArgs["ссылка"] or '', '%s*,%s*' )
 
  +
}
local ids = mw.text.split( blockArgs["спрайт"] or '', '%s*,%s*' )
 
  +
local materialSpeed = {
local items = mw.text.split( blockArgs["предмет"] or '', '%s*,%s*' )
 
  +
["Нет"] = 1,
for i, block in ipairs( blocks ) do
 
  +
["Любой"] = 1, ["Любая"] = 1,
local link
 
  +
["Деревянный"] = 2, ["Деревянная"] = 2,
if not links[i] and links[1] ~= '' then
 
  +
["Каменный"] = 4, ["Каменная"] = 4,
link = links[1]
 
  +
["Железный"] = 6, ["Железная"] = 6,
elseif links[i] ~= '' then
 
  +
["Алмазный"] = 8, ["Алмазная"] = 8,
link = links[i]
 
  +
["Незеритовый"] = 9, ["Незеритовая"] = 9,
end
 
  +
["Золотой"] = 12, ["Золотая"] = 12
local id
 
  +
}
if not ids[i] and ids[1] ~= '' then
 
  +
local numberMaterials = 6
id = ids[1]
 
  +
elseif ids[i] ~= '' then
 
  +
local function insertBlock( blockArgs )
id = ids[i]
 
  +
local cells = {}
end
 
  +
local blocks = mw.text.split( blockArgs[1], '%s*,%s*' )
local blockText
 
  +
local hardnessVal = tonumber( hardness{ blocks[1], ["тип"] = 'прочности' } )
if args["сократить"] then
 
  +
if not hardnessVal then
blockText = block:gsub( args["сократить"] .. '$', '' )
 
  +
hardnessVal = '?'
else
 
  +
local title = mw.title.getCurrentTitle()
blockText = block
 
  +
if title.namespace == 0 and not title.isSubpage then
end
 
  +
table.insert(categories, '[[Категория:Отсутствующие значения прочности]]')
local blockSpriteArgs = {
 
  +
end
["настройки"] = 'БлокСпрайт',
 
  +
end
block,
 
  +
local unbreakable
["текст"] = blockText,
 
  +
if hardnessVal == -1 or blockArgs.liquid then
["ссылка"] = link,
 
  +
unbreakable = true
["ID"] = id
 
  +
end
}
 
  +
if items[i] == '1' or not items[i] and items[1] == '1' then
 
  +
local blockSprites = {}
blockSpriteArgs.settings = 'ПредметСпрайт'
 
  +
local links = mw.text.split( blockArgs["ссылка"] or '', '%s*,%s*' )
end
 
  +
local ids = mw.text.split( blockArgs["спрайт"] or '', '%s*,%s*' )
 
  +
local items = mw.text.split( blockArgs["предмет"] or '', '%s*,%s*' )
local image, spriteCat = sprite.link( blockSpriteArgs )
 
  +
for i, block in ipairs( blocks ) do
table.insert( blockSprites, image )
 
  +
local link
table.insert( categories, spriteCat )
 
  +
if not links[i] and links[1] ~= '' then
end
 
  +
link = links[1]
table.insert( cells,
 
  +
elseif links[i] ~= '' then
'! style="text-align:left" | ' .. table.concat( blockSprites, '<br>' ) .. ( blockArgs["прим"] or '' )
 
  +
link = links[i]
)
 
  +
end
 
  +
local id
local tool = mw.text.trim( simple and 'Инструмент' or blockArgs[2] or 'Любое' ):gsub( '^%l', string.upper )
 
  +
if not ids[i] and ids[1] ~= '' then
local material = mw.text.trim( simple and blockArgs[2] or blockArgs[3] or 'Любое' ):gsub( '^%l', string.upper )
 
  +
id = ids[1]
if tool == 'Нет' then
 
  +
elseif ids[i] ~= '' then
material = tool
 
  +
id = ids[i]
end
 
  +
end
if not simple then
 
  +
local blockText
local hardnessText = hardnessVal
 
  +
if args["сократить"] then
if hardnessVal == -1 then
 
  +
blockText = block:gsub( args["сократить"] .. '$', '' )
hardnessText = ( sortable and 'data-sort-value="999" | ' or '' ) .. '∞'
 
  +
else
end
 
  +
blockText = block
table.insert( cells, '|' .. hardnessText )
 
  +
end
 
  +
local blockSpriteArgs = {
if showTool then
 
  +
["данные"] = 'Спрайт/Блок',
local toolCell = '—'
 
  +
block,
if tool ~= 'Любое' and tool ~= 'Нет' then
 
  +
["текст"] = blockText,
local toolName = ( material ~= 'Любое' and material .. ' ' or '' ) .. tool
 
local ftoolName = toolName
+
["ссылка"] = link,
  +
["ID"] = id
if material == 'Любое' then
 
  +
}
if tool == 'Кирка' then
 
  +
if items[i] == '1' or not items[i] and items[1] == '1' then
ftoolName = 'Деревянная кирка'
 
  +
blockSpriteArgs["данные"] = 'Спрайт/Предмет'
end
 
  +
end
if tool == 'Топор' then
 
  +
ftoolName = 'Деревянный топор'
 
  +
local image, spriteCat = sprite.link( blockSpriteArgs )
end
 
  +
table.insert( blockSprites, image )
if tool == 'Лопата' then
 
  +
table.insert( categories, spriteCat )
ftoolName = 'Деревянная лопата'
 
end
+
end
  +
table.insert( cells,
end
 
  +
'! style="text-align:left" | ' .. table.concat( blockSprites, '<br>' ) .. ( blockArgs["прим"] or '' )
local image, spriteCat = sprite.sprite{
 
  +
)
["настройки"] = 'ПредметСпрайт',
 
  +
ftoolName,
 
  +
local tool = mw.text.trim( simple and 'Инструмент' or blockArgs[2] or 'Любой' ):gsub( '^%l', string.upper )
["назв"] = toolName,
 
  +
local material = mw.text.trim( simple and blockArgs[2] or blockArgs[3] or 'Любой' ):gsub( '^%l', string.upper )
["ссылка"] = tool
 
  +
if tool == 'Нет' then
}
 
  +
material = tool
toolCell = ( sortable and 'data-sort-value="' .. toolName .. '" |' or '' ) .. image
 
  +
end
table.insert( categories, spriteCat )
 
  +
if not simple then
end
 
  +
local hardnessText = hardnessVal
table.insert( cells, '|' .. toolCell )
 
  +
if hardnessVal == -1 then
end
 
  +
hardnessText = ( sortable and 'data-sort-value="999" | ' or '' ) .. '∞'
end
 
  +
end
 
  +
table.insert( cells, '|' .. hardnessText )
local choices = {}
 
  +
local getChoice = function( choice, text )
 
  +
if showTool then
if not choices[choice] then
 
  +
local toolCell = '—'
choices[choice] = f:expandTemplate{ title = 'Таблица выбора', args = { choice, '' } }
 
  +
if tool ~= 'Любой' and tool ~= 'Нет' then
end
 
  +
local isMaterialSpecified = (material ~= 'Любой') and (material ~= 'Нет')
return choices[choice] .. text
 
  +
local toolName = ( isMaterialSpecified and material .. ' ' or '' ) .. tool
end
 
  +
if toolName == 'Топор' then
 
  +
wooden = 'Деревянный '
if hardnessVal == '?' then
 
  +
else
fillCells( cells, '|?', 6 )
 
  +
wooden = 'Деревянная '
else
 
  +
end
local processTime = function( num )
 
  +
local fullToolName = ( (not isMaterialSpecified) and wooden or '' ) .. toolName
if num < 0.05 then -- Blocks have a minimum breaking time of 1 game tick (0.05 seconds)
 
  +
local image, spriteCat = sprite.sprite{
num = 0.05
 
  +
["данные"] = 'Спрайт/Предмет',
else -- And they must be broken in multiples of 1 game tick (0.05 seconds)
 
  +
fullToolName,
num = math.ceil( num * 20 ) / 20
 
  +
["назв"] = toolName,
end
 
  +
["ссылка"] = tool
return num
 
  +
}
end
 
  +
toolCell = ( sortable and 'data-sort-value="' .. toolName .. '" |' or '' ) .. image
 
  +
table.insert( categories, spriteCat )
if unbreakable then
 
  +
end
table.insert( cells, '| ' .. ( sortable and 'data-sort-value="999" ' or '' ) .. getChoice( 'нет', '∞' ) )
 
  +
table.insert( cells, '|' .. toolCell )
if showTool then
 
  +
end
fillCells( cells, '|—', 5 )
 
end
+
end
  +
else
 
local drop = 'да'
+
local choices = {}
  +
local function getChoice( choice, text )
if blockArgs["дроп"] == '0' then
 
  +
if not choices[choice] then
drop = 'частично'
 
  +
choices[choice] = f:expandTemplate{ title = 'Таблица выбора', args = { choice, ''} }
end
 
  +
end
local requiredLevel = unbreakable and 999 or materialGrade[material]
 
  +
return choices[choice] .. text
local insertMaterialCell = function( material )
 
  +
end
local willDrop = drop
 
  +
if materialGrade[material] < requiredLevel then
 
  +
local function processTime( num )
willDrop = 'нет'
 
  +
-- переданное число было умножено на 100
end
 
  +
if num <= 5 then -- Минимальные временные затраты на разрушение блока равны 1 игровому такту (0,05 секунды)
local breakTime = processTime( hardnessVal / materialSpeed[material] * ( willDrop == 'нет' and 5 or 1.5 ) )
 
  +
num = 0.05
table.insert( cells, '|' .. getChoice( willDrop, breakTime ) )
 
  +
else -- Блоки должны быть разрушены кратно 1 игровому такту (0,05 секунды)
end
 
  +
num = math.ceil( num / 5 ) / 20
 
  +
end
if not showTool or tool == 'Любое' or tool == 'Нет' then
 
  +
return num
insertMaterialCell( 'Любое' )
 
  +
end
if showTool then
 
  +
fillCells( cells, '|—', 5 )
 
  +
if hardnessVal == '?' then
end
 
  +
fillCells( cells, '|?', numberMaterials + 1 )
else
 
  +
else
for _, material in ipairs{ 'Любое', 'Деревянный', 'Каменный', 'Железный', 'Алмазный', 'Золотой' } do
 
  +
if unbreakable then
insertMaterialCell( material )
 
  +
table.insert( cells, '| ' .. ( sortable and 'data-sort-value="999" ' or '' ) .. getChoice( 'no', '∞' ) )
end
 
  +
if showTool then
end
 
  +
fillCells( cells, '|—', numberMaterials )
end
 
  +
end
 
  +
else
if not simple and ( showShears or showSword ) then
 
local tools = {}
+
local drop = 'да'
  +
local forceDrop = false
if showShears then
 
  +
if blockArgs["дроп"] == '0' then
table.insert( tools, 'Ножницы' )
 
  +
drop = 'частично'
end
 
  +
elseif blockArgs["дроп"] == '1' then
if showSword then
 
  +
forceDrop = 'да'
table.insert( tools, 'Меч' )
 
  +
end
end
 
  +
local requiredLevel = unbreakable and 999 or materialGrade[material]
if hardnessVal == '?' then
 
  +
local function insertMaterialCell( material )
fillCells( cells, '|?', #tools )
 
  +
local shouldDrop = drop
else
 
  +
if materialGrade[material] < requiredLevel then
local toolSpeed = {
 
  +
shouldDrop = 'нет'
Shears = 1,
 
  +
end
Sword = 1.5
 
  +
-- предотвращение потери точности числа с плавающей запятой: умножить его на 100 и разделить в функции "processTime"
}
 
  +
local breakTime = processTime( hardnessVal * (shouldDrop == 'нет' and 500 or 150) / materialSpeed[material] )
if blocks[1] == 'Шерсть' then
 
  +
if breakTime == 0.05 then
toolSpeed.Shears = 5
 
  +
shouldDrop = "запланировано"
elseif blocks[1] == 'Листва' then
 
  +
end
toolSpeed.Shears = 15
 
  +
table.insert( cells, '|' .. getChoice( forceDrop or shouldDrop, breakTime ) )
elseif blocks[1] == 'Паутина' then
 
  +
end
toolSpeed.Sword = 15
 
  +
toolSpeed.Shears = 15
 
  +
if not showTool or tool == 'Любой' or tool == 'Нет' then
end
 
  +
insertMaterialCell( 'Любой' )
 
  +
if showTool then
for _, tool in ipairs( tools ) do
 
  +
fillCells( cells, '|—', numberMaterials )
local toolDrop = blockArgs[mw.ustring.lower( tool )]
 
  +
end
if not toolDrop then
 
  +
else
table.insert( cells, '|—' )
 
  +
for _, material in ipairs{ 'Любой', 'Деревянный', 'Каменный', 'Железный', 'Алмазный', 'Незеритовый', 'Золотой' } do
else
 
  +
insertMaterialCell( material )
local willDrop = 'да'
 
  +
end
if toolDrop == '0' then
 
  +
end
willDrop = 'частично'
 
  +
end
end
 
  +
end
 
  +
local breakTime = processTime( hardnessVal / toolSpeed[tool] * 1.5 )
 
  +
if not simple and ( showShears or showSword ) then
table.insert( cells, '|' .. getChoice( willDrop, breakTime ) )
 
  +
local tools = {}
end
 
  +
if showShears then
end
 
  +
table.insert( tools, 'Ножницы' )
end
 
  +
end
end
 
  +
if showSword then
end
 
  +
table.insert( tools, 'Меч' )
 
  +
end
if not horizontal then
 
  +
if hardnessVal == '?' then
cells = table.concat( cells, '\n' )
 
  +
fillCells( cells, '|?', #tools )
end
 
  +
else
table.insert( tableParts, cells )
 
  +
local toolSpeed = {
end
 
  +
["Ножницы"] = 1,
 
  +
["Меч"] = 1.5
if args[1] == '' or args[1]==nil then
 
  +
}
args[1] = mw.title.getCurrentTitle()
 
  +
if blocks[1] == 'Шерсть' then
end
 
  +
toolSpeed["Ножницы"] = 5
 
  +
elseif blocks[1] == 'Листва' then
if horizontal then
 
  +
toolSpeed["Ножницы"] = 15
local blocksArgs = {}
 
  +
elseif blocks[1] == 'Паутина' then
for _, arg in ipairs{ 1, 'прим', 'спрайт', 'ссылка', 'предмет', 'дроп', 2, 3, 'ножницы', 'меч' } do
 
  +
toolSpeed["Меч"] = 15
if args[arg] then
 
  +
toolSpeed["Ножницы"] = 15
local col = 0
 
  +
elseif blocks[1] == 'Бамбук' then
for colVal in mw.text.gsplit( args[arg], '%s*;%s*' ) do
 
  +
toolSpeed["Меч"] = 5000
col = col + 1
 
  +
end
if colVal ~= '' then
 
  +
if not blocksArgs[col] then
 
  +
for _, tool in ipairs( tools ) do
blocksArgs[col] = {}
 
  +
local toolDrop = blockArgs[mw.ustring.lower( tool )]
end
 
  +
if not toolDrop then
 
  +
table.insert( cells, '|—' )
blocksArgs[col][arg] = colVal
 
  +
else
end
 
  +
local willDrop = 'да'
end
 
  +
if toolDrop == '0' then
end
 
  +
willDrop = 'частично'
end
 
  +
end
for _, block in ipairs( blocksArgs ) do
 
  +
-- предотвращение потери точности числа с плавающей запятой: умножить его на 100 и разделить в функции "processTime"
insertBlock( block )
 
  +
local breakTime = processTime( hardnessVal * 150 / toolSpeed[tool] )
end
 
  +
if breakTime == 0.05 then
 
  +
willDrop = "запланировано"
local columns = #tableParts
 
  +
end
for row = 1, #tableParts[1] do
 
  +
table.insert( cells, '|' .. getChoice( willDrop, breakTime ) )
local cells = {}
 
  +
end
for col = 1, columns do
 
  +
end
table.insert( cells, tableParts[col][row] )
 
  +
end
end
 
  +
end
table.insert( rows, table.concat( cells, '\n' ) )
 
  +
end
 
  +
if not horizontal then
 
  +
cells = table.concat( cells, '\n' )
-- Insert breaking time header after block row when simple, or after tool or hardness row when not
 
  +
end
table.insert( rows, simple and 3 or showTool and 5 or 4, '! colspan="' .. columns + 1 .. '" |' .. breakingTimeHeader )
 
  +
table.insert( tableParts, cells )
else
 
  +
end
insertBlock( args )
 
  +
for _, row in ipairs( tableParts ) do
 
  +
if horizontal then
table.insert( rows, row )
 
  +
local blocksArgs = {}
end
 
  +
for _, arg in ipairs{ 1, 'прим', 'спрайт', 'ссылка', 'предмет', 'дроп', 2, 3, 'ножницы', 'меч' } do
end
 
  +
if args[arg] then
table.insert( rows, '' )
 
  +
local col = 0
 
  +
for colVal in mw.text.gsplit( args[arg], '%s*;%s*' ) do
local note = ''
 
  +
col = col + 1
if args["подвал"] or horizontal then
 
  +
if colVal ~= '' then
note = f:preprocess( '<references group="note"/>' )
 
  +
if not blocksArgs[col] then
 
  +
blocksArgs[col] = {}
if args["подвал"] == '2' then
 
  +
end
table.insert( rows, header or getDplVar( 'header' ) )
 
  +
end
 
  +
blocksArgs[col][arg] = colVal
table.insert( rows, '|}' )
 
  +
end
 
  +
end
if not horizontal then
 
  +
end
f:callParserFunction( '#dplvar:set',
 
  +
end
'breaking header', '',
 
  +
for _, block in ipairs( blocksArgs ) do
'breaking hidetool', '',
 
  +
insertBlock( block )
'breaking hideshears', '',
 
  +
end
'breaking hidesword', '',
 
  +
'breaking simple', '',
 
  +
local columns = #tableParts
'breaking sortable', ''
 
  +
for row = 1, #tableParts[1] do
)
 
  +
local cells = {}
end
 
  +
for col = 1, columns do
elseif #dplVars > 0 then
 
  +
table.insert( cells, tableParts[col][row] )
f:callParserFunction( '#dplvar:set', dplVars )
 
  +
end
end
 
  +
table.insert( rows, table.concat( cells, '\n' ) )
 
  +
end
return table.concat( rows, '\n|-\n' ) .. note .. table.concat( categories )
 
  +
  +
-- Вставка заголовка времени разрушения после строки блока при "simple", или после строки инструмента или твердости, если "simple" не используется
  +
table.insert( rows, simple and 3 or showTool and 5 or 4, '! colspan="' .. columns + 1 .. '" |' .. getBreakingTimeHeader( f ) )
  +
else
  +
insertBlock( args )
  +
for _, row in ipairs( tableParts ) do
  +
table.insert( rows, row )
  +
end
  +
end
  +
table.insert( rows, '' )
  +
  +
local note = ''
  +
if args["подвал"] or horizontal then
  +
note = f:preprocess( '<references group="FN"/>' )
  +
  +
if args["подвал"] == '2' then
  +
table.insert( rows, header or getDplVar( 'header' ) )
  +
end
  +
table.insert( rows, '|}' )
  +
  +
if not horizontal then
  +
f:callParserFunction( '#dplvar:set',
  +
'breaking header', '',
  +
'breaking hidetool', '',
  +
'breaking hideshears', '',
  +
'breaking hidesword', '',
  +
'breaking simple', '',
  +
'breaking sortable', ''
  +
)
  +
end
  +
elseif #dplVars > 0 then
  +
f:callParserFunction( '#dplvar:set', dplVars )
  +
end
  +
  +
return table.concat( rows, '\n|-\n' ) .. note .. table.concat( categories )
 
end
 
end
 
return p
 
return p

Текущая версия от 12:29, 9 июля 2021

local p = {}

local breakingTimeHeader;
local function getBreakingTimeHeader( f )
    if breakingTimeHeader == nil then
        breakingTimeHeader = 'Время [[Добывание|разрушения]]' .. f:preprocess( '<ref group="FN" name="breakingtimenote">Время для незачарованных инструментов, используемых игроком без наложенных эффектов, в секундах. Для большей информации см. [[Добывание#Скорость|Добывание § Скорость]].</ref>' )
    end
    return breakingTimeHeader
end

function p.row( f )
    local args = require( [[Модуль:ProcessArgs]] ).norm()
    local sprite = require( [[Модуль:Спрайт]] )

    local function getDplVar( var )
        local val = f:callParserFunction( '#dplvar', 'breaking ' .. var )
        if val == '' then
            val = false
        end
        return val
    end
    local dplVars = {}
    local function setDplVar( var, val )
        table.insert( dplVars, 'breaking ' .. var )
        table.insert( dplVars, val or '1' )
    end

    local rows = {}
    local tableParts = {}
    local categories = {}

    local horizontal
    args[1] = args[1] or '' -- чтобы не переделывать весь модуль, ранее считавший, что тут строка
    
    -- Подставляет название страницы, если параметр args[1] не указан.
    if (args[1] == '') or (args[1] == nil) then
		args[1] = mw.title.getCurrentTitle().text
		args["встолбик"] = 1
	end
	
    if args["встолбик"] or args[1]:match( ';' ) then
        horizontal = true
    end
    local showTool = true
    local showShears = true
    local showSword = true
    local header, sortable, simple
    if horizontal or not getDplVar( 'header' ) then
        if args["скрытьинструмент"] or horizontal and ( not args[2] or args[2]:lower() == 'any' or args[2]:lower() == 'none' ) then
            showTool = false
            setDplVar( 'hidetool' )
            breakingTimeHeader = 'Время [[Добывание|разрушения]]'
        end
        if args["скрытьножницы"] or horizontal and not args["ножницы"] then
            showShears = false
            setDplVar( 'hideshears' )
        end
        if args["скрытьмеч"] or horizontal and not args["меч"] then
            showSword = false
            setDplVar( 'hidesword' )
        end

        sortable = not horizontal and args["сортировка"]
        if sortable then
            setDplVar( 'sortable' )
        end
        simple = args["простой"]
        if simple and not horizontal then
            setDplVar( 'simple' )
        end

        local tableClasses = { 'wikitable' }
        if sortable then
            table.insert( tableClasses, 'sortable' )
        end
        table.insert( rows, ' {| class="' .. table.concat( tableClasses, ' ' ) .. '" style="text-align:center"' )

        local sortType = ''
        if sortable then
            sortType = 'data-sort-type="number"'
        end
        local rowspan = ''
        if not horizontal then
            rowspan = 'rowspan="2" '
        end
        header = {
            '! ' .. rowspan .. ' | Блок'
        }

        if not simple then
            table.insert( header, '! ' .. rowspan .. sortType .. ' | Прочность' )
            if showTool then
                table.insert( header, '! ' .. rowspan .. ' | Инструмент' )
            end
        end

        local toolColumns = {}
        if showTool then
            local firstTool = mw.text.trim( simple and 'Инструмент' or args[2] or 'Любой' ):gsub( '^%l', string.upper )
            firstTool = mw.text.split( firstTool, ';' )[1]
            if firstTool == 'Кирка' or firstTool == 'Лопата' or firstTool == 'Мотыга' then
                toolColumns = { 'Деревянная', 'Каменная', 'Железная', 'Алмазная', 'Незеритовая', 'Золотая' }
            else
                toolColumns = { 'Деревянный', 'Каменный', 'Железный', 'Алмазный', 'Незеритовый', 'Золотой' }
            end
        end
        table.insert( toolColumns, 1, 'По умолчанию' )

        if not simple then
            if showShears then
                table.insert( toolColumns, 'Ножницы' )
            end
            if showSword then
                table.insert( toolColumns, 'Меч' )
            end
        end

        if not horizontal then
            table.insert( header, '! colspan="' .. #toolColumns .. '" |' .. getBreakingTimeHeader( f ) )
            table.insert( header, '|-' )
        end

        local toolSprites = {
            ["Деревянный"] = {'Спрайт/Блок', 'дубовые-доски' },
            ["Деревянная"] = {'Спрайт/Блок', 'дубовые-доски' },
            ["Каменный"] = { 'Спрайт/Блок', 'булыжник' },
            ["Каменная"] = { 'Спрайт/Блок', 'булыжник' },
            ["Железный"] = { 'Спрайт/Предмет', 'железный-слиток' },
            ["Железная"] = { 'Спрайт/Предмет', 'железный-слиток' },
            ["Алмазный"] = { 'Спрайт/Предмет', 'алмаз' },
            ["Алмазная"] = { 'Спрайт/Предмет', 'алмаз' },
            ["Незеритовый"] = { 'Спрайт/Предмет', 'незеритовый-слиток' },
            ["Незеритовая"] = { 'Спрайт/Предмет', 'незеритовый-слиток' },
            ["Золотой"] = { 'Спрайт/Предмет', 'золотой-слиток' },
            ["Золотая"] = { 'Спрайт/Предмет', 'золотой-слиток' },
            ["Ножницы"] = { 'Спрайт/Предмет', 'ножницы' },
            ["Меч"] = { 'Спрайт/Предмет', 'деревянный-меч' }
        }
        for _, tool in ipairs( toolColumns ) do
            if toolSprites[tool] then
                local image, spriteCat = sprite.sprite{
                    ["данные"] = toolSprites[tool][1],
                    toolSprites[tool][2],
                    ["текст"] = tool
                }
                table.insert( header, '! style="text-align:left" ' .. sortType .. ' | ' .. image )
                table.insert( categories, spriteCat )
            else
                table.insert( header, '! ' .. sortType .. ' | ' .. tool )
            end
        end

        if not horizontal then
            header = table.concat( header, '\n' )
            setDplVar( 'header', header )
        end
        table.insert( tableParts, header )
    else
        showTool = not getDplVar( 'hidetool' )
        showShears = not getDplVar( 'hideshears' )
        showSword = not getDplVar( 'hidesword' )
        sortable = getDplVar( 'sortable' )
        simple = getDplVar( 'simple' )
    end

    local hardness = require( [[Модуль:Значения блоков]] ).value

    local function fillCells( cellsTable, text, num )
        for i = 1, num do
            table.insert( cellsTable, text )
        end
    end
    local materialGrade = {
        ["Любой"] = 0, ["Любая"] = 0,
        ["Деревянный"] = 1, ["Деревянная"] = 1,
        ["Золотой"] = 1, ["Золотая"] = 1,
        ["Каменный"] = 2, ["Каменная"] = 2,
        ["Железный"] = 3, ["Железная"] = 3,
        ["Алмазный"] = 4, ["Алмазная"] = 4,
        ["Незеритовый"] = 5, ["Незеритовая"] = 5,
        ["Нет"] = 6
    }
    local materialSpeed = {
        ["Нет"] = 1,
        ["Любой"] = 1, ["Любая"] = 1,
        ["Деревянный"] = 2, ["Деревянная"] = 2,
        ["Каменный"] = 4, ["Каменная"] = 4,
        ["Железный"] = 6, ["Железная"] = 6,
        ["Алмазный"] = 8, ["Алмазная"] = 8,
        ["Незеритовый"] = 9, ["Незеритовая"] = 9,
        ["Золотой"] = 12, ["Золотая"] = 12
    }
    local numberMaterials = 6

    local function insertBlock( blockArgs )
        local cells = {}
        local blocks = mw.text.split( blockArgs[1], '%s*,%s*' )
        local hardnessVal = tonumber( hardness{ blocks[1], ["тип"] = 'прочности' } )
        if not hardnessVal then
            hardnessVal = '?'
            local title = mw.title.getCurrentTitle()
            if title.namespace == 0 and not title.isSubpage then
                table.insert(categories, '[[Категория:Отсутствующие значения прочности]]')
            end
        end
        local unbreakable
        if hardnessVal == -1 or blockArgs.liquid then
            unbreakable = true
        end

        local blockSprites = {}
        local links = mw.text.split( blockArgs["ссылка"] or '', '%s*,%s*' )
        local ids = mw.text.split( blockArgs["спрайт"] or '', '%s*,%s*' )
        local items = mw.text.split( blockArgs["предмет"] or '', '%s*,%s*' )
        for i, block in ipairs( blocks ) do
            local link
            if not links[i] and links[1] ~= '' then
                link = links[1]
            elseif links[i] ~= '' then
                link = links[i]
            end
            local id
            if not ids[i] and ids[1] ~= '' then
                id = ids[1]
            elseif ids[i] ~= '' then
                id = ids[i]
            end
            local blockText
            if args["сократить"] then
                blockText = block:gsub( args["сократить"] .. '$', '' )
            else
                blockText = block
            end
            local blockSpriteArgs = {
                ["данные"] = 'Спрайт/Блок',
                block,
                ["текст"] = blockText,
                ["ссылка"] = link,
                ["ID"] = id
            }
            if items[i] == '1' or not items[i] and items[1] == '1' then
                blockSpriteArgs["данные"] = 'Спрайт/Предмет'
            end

            local image, spriteCat = sprite.link( blockSpriteArgs )
            table.insert( blockSprites, image )
            table.insert( categories, spriteCat )
        end
        table.insert( cells,
            '! style="text-align:left" | ' .. table.concat( blockSprites, '<br>' ) .. ( blockArgs["прим"] or '' )
        )

        local tool = mw.text.trim( simple and 'Инструмент' or blockArgs[2] or 'Любой' ):gsub( '^%l', string.upper )
        local material = mw.text.trim( simple and blockArgs[2] or blockArgs[3] or 'Любой' ):gsub( '^%l', string.upper )
        if tool == 'Нет' then
            material = tool
        end
        if not simple then
            local hardnessText = hardnessVal
            if hardnessVal == -1 then
                hardnessText = ( sortable and 'data-sort-value="999" | ' or '' ) .. '∞'
            end
            table.insert( cells, '|' .. hardnessText )

            if showTool then
                local toolCell = '—'
                if tool ~= 'Любой' and tool ~= 'Нет' then
                    local isMaterialSpecified = (material ~= 'Любой') and (material ~= 'Нет')
                    local toolName = ( isMaterialSpecified and material .. ' ' or '' ) .. tool
                    if toolName == 'Топор' then
                    	wooden = 'Деревянный '
                    else 
                    	wooden = 'Деревянная '
                    end
                    local fullToolName = ( (not isMaterialSpecified) and wooden or '' ) .. toolName
                    local image, spriteCat = sprite.sprite{
                        ["данные"] = 'Спрайт/Предмет',
                        fullToolName,
                        ["назв"] = toolName,
                        ["ссылка"] = tool
                    }
                    toolCell = ( sortable and 'data-sort-value="' .. toolName .. '" |' or '' ) .. image
                    table.insert( categories, spriteCat )
                end
                table.insert( cells, '|' .. toolCell )
            end
        end

        local choices = {}
        local function getChoice( choice, text )
            if not choices[choice] then
                choices[choice] = f:expandTemplate{ title = 'Таблица выбора', args = { choice, ''} }
            end
            return choices[choice] .. text
        end

        local function processTime( num )
            -- переданное число было умножено на 100
            if num <= 5 then        -- Минимальные временные затраты на разрушение блока равны 1 игровому такту (0,05 секунды)
                num = 0.05
            else                    -- Блоки должны быть разрушены кратно 1 игровому такту (0,05 секунды)
                num = math.ceil( num / 5 ) / 20
            end
            return num
        end

        if hardnessVal == '?' then
            fillCells( cells, '|?', numberMaterials + 1 )
        else
            if unbreakable then
                table.insert( cells, '| ' .. ( sortable and 'data-sort-value="999" ' or '' ) .. getChoice( 'no', '∞' ) )
                if showTool then
                    fillCells( cells, '|—', numberMaterials )
                end
            else
                local drop = 'да'
                local forceDrop = false
                if blockArgs["дроп"] == '0' then
                    drop = 'частично'
                elseif blockArgs["дроп"] == '1' then
                     forceDrop = 'да'
                 end
                 local requiredLevel = unbreakable and 999 or materialGrade[material]
                 local function insertMaterialCell( material )
                     local shouldDrop = drop
                    if materialGrade[material] < requiredLevel then
                        shouldDrop = 'нет'
                    end
                    -- предотвращение потери точности числа с плавающей запятой: умножить его на 100 и разделить в функции "processTime"
                    local breakTime = processTime( hardnessVal * (shouldDrop == 'нет' and 500 or 150) / materialSpeed[material] )
                    if breakTime == 0.05 then
                        shouldDrop = "запланировано"
                    end
                    table.insert( cells, '|' .. getChoice( forceDrop or shouldDrop, breakTime ) )
                end

                 if not showTool or tool == 'Любой' or tool == 'Нет' then
                     insertMaterialCell( 'Любой' )
                    if showTool then
                        fillCells( cells, '|—', numberMaterials )
                    end
                else
                    for _, material in ipairs{ 'Любой', 'Деревянный', 'Каменный', 'Железный', 'Алмазный', 'Незеритовый', 'Золотой' } do
                        insertMaterialCell( material )
                    end
                end
            end
        end

        if not simple and ( showShears or showSword ) then
            local tools = {}
            if showShears then
                table.insert( tools, 'Ножницы' )
            end
            if showSword then
                table.insert( tools, 'Меч' )
            end
            if hardnessVal == '?' then
                fillCells( cells, '|?', #tools )
            else
                local toolSpeed = {
                    ["Ножницы"] = 1,
                    ["Меч"] = 1.5
                }
                if blocks[1] == 'Шерсть' then
                    toolSpeed["Ножницы"] = 5
                elseif blocks[1] == 'Листва' then
                    toolSpeed["Ножницы"] = 15
                elseif blocks[1] == 'Паутина' then
                    toolSpeed["Меч"] = 15
                    toolSpeed["Ножницы"] = 15
                elseif blocks[1] == 'Бамбук' then
                    toolSpeed["Меч"] = 5000
                end

                for _, tool in ipairs( tools ) do
                    local toolDrop = blockArgs[mw.ustring.lower( tool )]
                    if not toolDrop then
                        table.insert( cells, '|—' )
                    else
                        local willDrop = 'да'
                        if toolDrop == '0' then
                            willDrop = 'частично'
                        end
                        -- предотвращение потери точности числа с плавающей запятой: умножить его на 100 и разделить в функции "processTime"
                        local breakTime = processTime( hardnessVal * 150 / toolSpeed[tool] )
                        if breakTime == 0.05 then
                            willDrop = "запланировано"
                        end
                        table.insert( cells, '|' .. getChoice( willDrop, breakTime ) )
                    end
                end
            end
        end

        if not horizontal then
            cells = table.concat( cells, '\n' )
        end
        table.insert( tableParts, cells )
    end

    if horizontal then
        local blocksArgs = {}
        for _, arg in ipairs{ 1, 'прим', 'спрайт', 'ссылка', 'предмет', 'дроп', 2, 3, 'ножницы', 'меч' } do
            if args[arg] then
                local col = 0
                for colVal in mw.text.gsplit( args[arg], '%s*;%s*' ) do
                    col = col + 1
                    if colVal ~= '' then
                        if not blocksArgs[col] then
                            blocksArgs[col] = {}
                        end

                        blocksArgs[col][arg] = colVal
                    end
                end
            end
        end
        for _, block in ipairs( blocksArgs ) do
            insertBlock( block )
        end

        local columns = #tableParts
        for row = 1, #tableParts[1] do
            local cells = {}
            for col = 1, columns do
                table.insert( cells, tableParts[col][row] )
            end
            table.insert( rows, table.concat( cells, '\n' ) )
        end

        -- Вставка заголовка времени разрушения после строки блока при "simple", или после строки инструмента или твердости, если "simple" не используется
        table.insert( rows, simple and 3 or showTool and 5 or 4, '! colspan="' .. columns + 1 .. '" |' .. getBreakingTimeHeader( f ) )
    else
        insertBlock( args )
        for _, row in ipairs( tableParts ) do
            table.insert( rows, row )
        end
    end
    table.insert( rows, '' )

    local note = ''
    if args["подвал"] or horizontal then
        note = f:preprocess( '<references group="FN"/>' )

        if args["подвал"] == '2' then
            table.insert( rows, header or getDplVar( 'header' ) )
        end
        table.insert( rows, '|}' )

        if not horizontal then
            f:callParserFunction( '#dplvar:set',
                'breaking header', '',
                'breaking hidetool', '',
                'breaking hideshears', '',
                'breaking hidesword', '',
                'breaking simple', '',
                'breaking sortable', ''
            )
        end
    elseif #dplVars > 0 then
         f:callParserFunction( '#dplvar:set', dplVars )
    end

    return table.concat( rows, '\n|-\n' ) .. note .. table.concat( categories )
end
return p