User-100181356 (discusión | contribs.) mSin resumen de edición |
Sin resumen de edición Etiqueta: Reversión manual |
||
(No se muestran 18 ediciones intermedias de 3 usuarios) | |||
Línea 4: | Línea 4: | ||
local function getBreakingTimeHeader( f ) |
local function getBreakingTimeHeader( f ) |
||
if breakingTimeHeader == nil then |
if breakingTimeHeader == nil then |
||
− | breakingTimeHeader = 'Tiempo de [[ |
+ | breakingTimeHeader = 'Tiempo de [[rotura]]' .. f:preprocess( '<ref group="nota" name="breakingtimenote">Los tiempos son para herramientas sin encantar sostenidas por jugadores sin efectos de estado, medidos en segundos. Para más información, véase [[Minería#Velocidad|Minería § Velocidad]].</ref>' ) |
end |
end |
||
return breakingTimeHeader |
return breakingTimeHeader |
||
Línea 11: | Línea 11: | ||
function p.row( f ) |
function p.row( f ) |
||
local args = require( [[Módulo:ProcessArgs]] ).norm() |
local args = require( [[Módulo:ProcessArgs]] ).norm() |
||
⚫ | |||
local function getDplVar( var ) |
local function getDplVar( var ) |
||
Línea 38: | Línea 39: | ||
local header, sortable, simple |
local header, sortable, simple |
||
if horizontal or not getDplVar( 'header' ) then |
if horizontal or not getDplVar( 'header' ) then |
||
− | if args.hidetool or horizontal and ( not args[2] or args[2]:lower() == ' |
+ | if args.hidetool or horizontal and ( not args[2] or args[2]:lower() == 'cualquier' or args[2]:lower() == 'ninguno' ) then |
showTool = false |
showTool = false |
||
setDplVar( 'hidetool' ) |
setDplVar( 'hidetool' ) |
||
− | breakingTimeHeader = '[[ |
+ | breakingTimeHeader = 'Tiempo de [[rotura]]' |
end |
end |
||
if args.hideshears or horizontal and not args.shears then |
if args.hideshears or horizontal and not args.shears then |
||
Línea 61: | Línea 62: | ||
end |
end |
||
− | local tableClasses = { 'wikitable' } |
+ | local tableClasses = { 'wikitable fandom-table' } |
if sortable then |
if sortable then |
||
table.insert( tableClasses, 'sortable' ) |
table.insert( tableClasses, 'sortable' ) |
||
Línea 76: | Línea 77: | ||
end |
end |
||
header = { |
header = { |
||
− | '! ' .. rowspan .. ' | |
+ | '! ' .. rowspan .. ' | Bloque' |
} |
} |
||
if not simple then |
if not simple then |
||
− | table.insert( header, '! ' .. rowspan .. sortType .. ' | |
+ | table.insert( header, '! ' .. rowspan .. sortType .. ' | Dureza' ) |
if showTool then |
if showTool then |
||
− | table.insert( header, '! ' .. rowspan .. ' | |
+ | table.insert( header, '! ' .. rowspan .. ' | Herramienta' ) |
end |
end |
||
end |
end |
||
Línea 88: | Línea 89: | ||
local toolColumns = {} |
local toolColumns = {} |
||
if showTool then |
if showTool then |
||
− | toolColumns = { ' |
+ | toolColumns = { 'Madera', 'Piedra', 'Hierro', 'Diamante', 'Netherita', 'Oro'} |
end |
end |
||
− | table.insert( toolColumns, 1, ' |
+ | table.insert( toolColumns, 1, 'Por defecto' ) |
if not simple then |
if not simple then |
||
if showShears then |
if showShears then |
||
− | table.insert( toolColumns, ' |
+ | table.insert( toolColumns, 'Tijeras' ) |
end |
end |
||
if showSword then |
if showSword then |
||
− | table.insert( toolColumns, ' |
+ | table.insert( toolColumns, 'Espada' ) |
end |
end |
||
end |
end |
||
Línea 106: | Línea 107: | ||
end |
end |
||
⚫ | |||
+ | Wooden = { 'BlockSprite', 'tablones-de-roble' }, |
||
+ | Stone = { 'BlockSprite', 'roca' }, |
||
+ | Iron = { 'ItemSprite', 'lingote-de-hierro' }, |
||
+ | Diamond = { 'ItemSprite', 'diamante' }, |
||
+ | Netherite = { 'ItemSprite', 'lingote-de-netherita' }, |
||
+ | Golden = { 'ItemSprite', 'lingote-de-oro' }, |
||
+ | Shears = { 'ItemSprite', 'tijeras' }, |
||
+ | Sword = { 'ItemSprite', 'espada-de-madera' } |
||
⚫ | |||
for _, tool in ipairs( toolColumns ) do |
for _, tool in ipairs( toolColumns ) do |
||
+ | if toolSprites[tool] then |
||
⚫ | |||
+ | local image, spriteCat = sprite.sprite{ |
||
+ | data = toolSprites[tool][1], |
||
+ | toolSprites[tool][2], |
||
⚫ | |||
⚫ | |||
+ | table.insert( header, '! style="text-align:left" ' .. sortType .. ' | ' .. image ) |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Línea 123: | Línea 144: | ||
end |
end |
||
⚫ | |||
local hardness = require( [[Módulo:Block value]] ).value |
local hardness = require( [[Módulo:Block value]] ).value |
||
Línea 132: | Línea 152: | ||
end |
end |
||
local materialGrade = { |
local materialGrade = { |
||
− | + | Cualquiera = 0, |
|
− | + | Madera = 1, Madera = 1, |
|
− | + | Oro = 1, |
|
− | + | Piedra = 2, |
|
− | + | Hierro = 3, |
|
− | + | Diamante = 4, |
|
− | + | Netherita = 5, |
|
− | + | Ninguno = 6 |
|
} |
} |
||
local materialSpeed = { |
local materialSpeed = { |
||
− | + | Ninguno = 1, |
|
− | + | Cualquiera = 1, |
|
− | + | Madera = 2, Madera = 2, |
|
− | + | Piedra = 4, |
|
− | + | Hierro = 6, |
|
− | + | Diamante = 8, |
|
− | + | Netherita = 9, |
|
− | + | Oro = 12 |
|
} |
} |
||
local numberMaterials = 6 |
local numberMaterials = 6 |
||
Línea 161: | Línea 181: | ||
local title = mw.title.getCurrentTitle() |
local title = mw.title.getCurrentTitle() |
||
if title.namespace == 0 and not title.isSubpage then |
if title.namespace == 0 and not title.isSubpage then |
||
− | table.insert(categories, '[[ |
+ | table.insert(categories, '[[Categoría:Dureza faltante]]') |
end |
end |
||
end |
end |
||
Línea 211: | Línea 231: | ||
) |
) |
||
− | local tool = mw.text.trim( simple and ' |
+ | local tool = mw.text.trim( simple and 'Herramienta' or blockArgs[2] or 'Cualquiera' ):gsub( '^%l', string.upper ) |
− | local material = mw.text.trim( simple and blockArgs[2] or blockArgs[3] or ' |
+ | local material = mw.text.trim( simple and blockArgs[2] or blockArgs[3] or 'Cualquiera' ):gsub( '^%l', string.upper ) |
− | if tool == ' |
+ | if tool == 'Ninguno' then |
material = tool |
material = tool |
||
end |
end |
||
Línea 225: | Línea 245: | ||
if showTool then |
if showTool then |
||
local toolCell = '—' |
local toolCell = '—' |
||
− | if tool ~= ' |
+ | if tool ~= 'Cualquiera' and tool ~= 'Ninguno' then |
if material == 'Madera' then |
if material == 'Madera' then |
||
material = 'Madera' |
material = 'Madera' |
||
end |
end |
||
− | local |
+ | local isMaterialSpecified = (material ~= 'Cualquiera') and (material ~= 'Ninguno') |
+ | local toolName = tool .. ( isMaterialSpecified and ' de ' .. material or '' ) |
||
+ | local fullToolName = toolName .. ( (not isMaterialSpecified) and ' de madera' or '' ) |
||
local image, spriteCat = sprite.sprite{ |
local image, spriteCat = sprite.sprite{ |
||
data = 'ItemSprite', |
data = 'ItemSprite', |
||
+ | fullToolName, |
||
− | ( material == 'Any' and 'Madera ' or '' ) .. toolName, |
||
title = toolName, |
title = toolName, |
||
link = tool |
link = tool |
||
Línea 246: | Línea 268: | ||
local function getChoice( choice, text ) |
local function getChoice( choice, text ) |
||
if not choices[choice] then |
if not choices[choice] then |
||
− | choices[choice] = f:expandTemplate{ title = 'Table |
+ | choices[choice] = f:expandTemplate{ title = 'Table choice', args = { choice, '' } } |
end |
end |
||
return choices[choice] .. text |
return choices[choice] .. text |
||
⚫ | |||
+ | |||
⚫ | |||
+ | -- the number passed in has been multiplied by 100 |
||
⚫ | |||
+ | num = 0.05 |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Línea 254: | Línea 286: | ||
fillCells( cells, '|?', numberMaterials + 1 ) |
fillCells( cells, '|?', numberMaterials + 1 ) |
||
else |
else |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if unbreakable then |
if unbreakable then |
||
table.insert( cells, '| ' .. ( sortable and 'data-sort-value="999" ' or '' ) .. getChoice( 'no', '∞' ) ) |
table.insert( cells, '| ' .. ( sortable and 'data-sort-value="999" ' or '' ) .. getChoice( 'no', '∞' ) ) |
||
Línea 269: | Línea 292: | ||
end |
end |
||
else |
else |
||
− | local drop = ' |
+ | local drop = 'si' |
local forceDrop = false |
local forceDrop = false |
||
if blockArgs.drop == '0' then |
if blockArgs.drop == '0' then |
||
− | drop = ' |
+ | drop = 'parcial' |
elseif blockArgs.drop == '1' then |
elseif blockArgs.drop == '1' then |
||
− | forceDrop = ' |
+ | forceDrop = 'si' |
end |
end |
||
local requiredLevel = unbreakable and 999 or materialGrade[material] |
local requiredLevel = unbreakable and 999 or materialGrade[material] |
||
Línea 282: | Línea 305: | ||
shouldDrop = 'no' |
shouldDrop = 'no' |
||
end |
end |
||
+ | -- prevent float number precision loss, multiply by 100 and divide it in processTime function |
||
− | local breakTime = processTime( hardnessVal |
+ | local breakTime = processTime( hardnessVal * (shouldDrop == 'no' and 500 or 150) / materialSpeed[material] ) |
⚫ | |||
+ | shouldDrop = "planeado" |
||
⚫ | |||
table.insert( cells, '|' .. getChoice( forceDrop or shouldDrop, breakTime ) ) |
table.insert( cells, '|' .. getChoice( forceDrop or shouldDrop, breakTime ) ) |
||
end |
end |
||
− | if not showTool or tool == ' |
+ | if not showTool or tool == 'Cualquiera' or tool == 'Ninguno' then |
− | insertMaterialCell( ' |
+ | insertMaterialCell( 'Cualquiera' ) |
if showTool then |
if showTool then |
||
fillCells( cells, '|—', numberMaterials ) |
fillCells( cells, '|—', numberMaterials ) |
||
end |
end |
||
else |
else |
||
− | for _, material in ipairs{ ' |
+ | for _, material in ipairs{ 'Cualquiera', 'Madera', 'Piedra', 'Hierro', 'Diamante', 'Netherita', 'Oro' } do |
insertMaterialCell( material ) |
insertMaterialCell( material ) |
||
end |
end |
||
end |
end |
||
end |
end |
||
− | + | end |
|
+ | |||
− | + | if not simple and ( showShears or showSword ) then |
|
⚫ | |||
− | + | local tools = {} |
|
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | fillCells( cells, '|?', #tools ) |
||
+ | else |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | } |
||
⚫ | |||
+ | toolSpeed.Shears = 5 |
||
+ | elseif blocks[1] == 'Hojas' then |
||
+ | toolSpeed.Shears = 15 |
||
+ | elseif blocks[1] == 'Telaraña' then |
||
+ | toolSpeed.Sword = 15 |
||
+ | toolSpeed.Shears = 15 |
||
+ | elseif blocks[1] =='Bambú' then |
||
+ | toolSpeed.Sword = 5000 |
||
end |
end |
||
+ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | if |
+ | if not toolDrop then |
− | + | table.insert( cells, '|—' ) |
|
− | else |
+ | else |
− | local |
+ | local willDrop = 'yes' |
− | + | if toolDrop == '0' then |
|
− | + | willDrop = 'partial' |
|
− | + | end |
|
+ | -- prevent float number precision loss, multiply by 100 and divide it in processTime function |
||
⚫ | |||
⚫ | |||
⚫ | |||
− | + | if breakTime == 0.05 then |
|
− | + | willDrop = "planned" |
|
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | local willDrop = 'yes' |
||
⚫ | |||
− | willDrop = 'partial' |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
⚫ | |||
end |
end |
||
end |
end |
||
Línea 388: | Línea 420: | ||
local note = '' |
local note = '' |
||
if args.foot or horizontal then |
if args.foot or horizontal then |
||
− | note = f:preprocess( '<references group=" |
+ | note = f:preprocess( '<references group="nota"/>' ) |
if args.foot == '2' then |
if args.foot == '2' then |
Revisión actual - 04:35 20 may 2023
Este módulo implementa {{breaking row}}
Dependencias
[Ver | Editar | Purgar]La documentación arriba es transcluída desde Módulo:Breaking row/doc.
local p = {}
local breakingTimeHeader;
local function getBreakingTimeHeader( f )
if breakingTimeHeader == nil then
breakingTimeHeader = 'Tiempo de [[rotura]]' .. f:preprocess( '<ref group="nota" name="breakingtimenote">Los tiempos son para herramientas sin encantar sostenidas por jugadores sin efectos de estado, medidos en segundos. Para más información, véase [[Minería#Velocidad|Minería § Velocidad]].</ref>' )
end
return breakingTimeHeader
end
function p.row( f )
local args = require( [[Módulo:ProcessArgs]] ).norm()
local sprite = require( [[Módulo:Sprite]] )
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
if args.horizontal 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.hidetool or horizontal and ( not args[2] or args[2]:lower() == 'cualquier' or args[2]:lower() == 'ninguno' ) then
showTool = false
setDplVar( 'hidetool' )
breakingTimeHeader = 'Tiempo de [[rotura]]'
end
if args.hideshears or horizontal and not args.shears then
showShears = false
setDplVar( 'hideshears' )
end
if args.hidesword or horizontal and not args.sword then
showSword = false
setDplVar( 'hidesword' )
end
sortable = not horizontal and args.sort
if sortable then
setDplVar( 'sortable' )
end
simple = args.simple
if simple and not horizontal then
setDplVar( 'simple' )
end
local tableClasses = { 'wikitable fandom-table' }
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 .. ' | Bloque'
}
if not simple then
table.insert( header, '! ' .. rowspan .. sortType .. ' | Dureza' )
if showTool then
table.insert( header, '! ' .. rowspan .. ' | Herramienta' )
end
end
local toolColumns = {}
if showTool then
toolColumns = { 'Madera', 'Piedra', 'Hierro', 'Diamante', 'Netherita', 'Oro'}
end
table.insert( toolColumns, 1, 'Por defecto' )
if not simple then
if showShears then
table.insert( toolColumns, 'Tijeras' )
end
if showSword then
table.insert( toolColumns, 'Espada' )
end
end
if not horizontal then
table.insert( header, '! colspan="' .. #toolColumns .. '" |' .. getBreakingTimeHeader( f ) )
table.insert( header, '|-' )
end
local toolSprites = {
Wooden = { 'BlockSprite', 'tablones-de-roble' },
Stone = { 'BlockSprite', 'roca' },
Iron = { 'ItemSprite', 'lingote-de-hierro' },
Diamond = { 'ItemSprite', 'diamante' },
Netherite = { 'ItemSprite', 'lingote-de-netherita' },
Golden = { 'ItemSprite', 'lingote-de-oro' },
Shears = { 'ItemSprite', 'tijeras' },
Sword = { 'ItemSprite', 'espada-de-madera' }
}
for _, tool in ipairs( toolColumns ) do
if toolSprites[tool] then
local image, spriteCat = sprite.sprite{
data = toolSprites[tool][1],
toolSprites[tool][2],
text = 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( [[Módulo:Block value]] ).value
local function fillCells( cellsTable, text, num )
for i = 1, num do
table.insert( cellsTable, text )
end
end
local materialGrade = {
Cualquiera = 0,
Madera = 1, Madera = 1,
Oro = 1,
Piedra = 2,
Hierro = 3,
Diamante = 4,
Netherita = 5,
Ninguno = 6
}
local materialSpeed = {
Ninguno = 1,
Cualquiera = 1,
Madera = 2, Madera = 2,
Piedra = 4,
Hierro = 6,
Diamante = 8,
Netherita = 9,
Oro = 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], type = 'hardness' } )
if not hardnessVal then
hardnessVal = '?'
local title = mw.title.getCurrentTitle()
if title.namespace == 0 and not title.isSubpage then
table.insert(categories, '[[Categoría:Dureza faltante]]')
end
end
local unbreakable
if hardnessVal == -1 or blockArgs.liquid then
unbreakable = true
end
local blockSprites = {}
local links = mw.text.split( blockArgs.link or '', '%s*,%s*' )
local ids = mw.text.split( blockArgs.sprite or '', '%s*,%s*' )
local items = mw.text.split( blockArgs.item 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.textTrim then
blockText = block:gsub( args.textTrim .. '$', '' )
else
blockText = block
end
local blockSpriteArgs = {
data = 'BlockSprite',
block,
text = blockText,
link = link,
id = id
}
if items[i] == '1' or not items[i] and items[1] == '1' then
blockSpriteArgs.data = 'ItemSprite'
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.note or '' )
)
local tool = mw.text.trim( simple and 'Herramienta' or blockArgs[2] or 'Cualquiera' ):gsub( '^%l', string.upper )
local material = mw.text.trim( simple and blockArgs[2] or blockArgs[3] or 'Cualquiera' ):gsub( '^%l', string.upper )
if tool == 'Ninguno' 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 ~= 'Cualquiera' and tool ~= 'Ninguno' then
if material == 'Madera' then
material = 'Madera'
end
local isMaterialSpecified = (material ~= 'Cualquiera') and (material ~= 'Ninguno')
local toolName = tool .. ( isMaterialSpecified and ' de ' .. material or '' )
local fullToolName = toolName .. ( (not isMaterialSpecified) and ' de madera' or '' )
local image, spriteCat = sprite.sprite{
data = 'ItemSprite',
fullToolName,
title = toolName,
link = 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 = 'Table choice', args = { choice, '' } }
end
return choices[choice] .. text
end
local function processTime( num )
-- the number passed in has been multiplied by 100
if num <= 5 then -- Blocks have a minimum breaking time of 1 game tick (0.05 seconds)
num = 0.05
else -- And they must be broken in multiples of 1 game tick (0.05 seconds)
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 = 'si'
local forceDrop = false
if blockArgs.drop == '0' then
drop = 'parcial'
elseif blockArgs.drop == '1' then
forceDrop = 'si'
end
local requiredLevel = unbreakable and 999 or materialGrade[material]
local function insertMaterialCell( material )
local shouldDrop = drop
if materialGrade[material] < requiredLevel then
shouldDrop = 'no'
end
-- prevent float number precision loss, multiply by 100 and divide it in processTime function
local breakTime = processTime( hardnessVal * (shouldDrop == 'no' and 500 or 150) / materialSpeed[material] )
if breakTime == 0.05 then
shouldDrop = "planeado"
end
table.insert( cells, '|' .. getChoice( forceDrop or shouldDrop, breakTime ) )
end
if not showTool or tool == 'Cualquiera' or tool == 'Ninguno' then
insertMaterialCell( 'Cualquiera' )
if showTool then
fillCells( cells, '|—', numberMaterials )
end
else
for _, material in ipairs{ 'Cualquiera', 'Madera', 'Piedra', 'Hierro', 'Diamante', 'Netherita', 'Oro' } do
insertMaterialCell( material )
end
end
end
end
if not simple and ( showShears or showSword ) then
local tools = {}
if showShears then
table.insert( tools, 'Tijeras' )
end
if showSword then
table.insert( tools, 'Espada' )
end
if hardnessVal == '?' then
fillCells( cells, '|?', #tools )
else
local toolSpeed = {
Shears = 1,
Sword = 1.5
}
if blocks[1] == 'Lana' then
toolSpeed.Shears = 5
elseif blocks[1] == 'Hojas' then
toolSpeed.Shears = 15
elseif blocks[1] == 'Telaraña' then
toolSpeed.Sword = 15
toolSpeed.Shears = 15
elseif blocks[1] =='Bambú' then
toolSpeed.Sword = 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 = 'yes'
if toolDrop == '0' then
willDrop = 'partial'
end
-- prevent float number precision loss, multiply by 100 and divide it in processTime function
local breakTime = processTime( hardnessVal * 150 / toolSpeed[tool] )
if breakTime == 0.05 then
willDrop = "planned"
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, 'note', 'sprite', 'link', 'item', 'drop', 2, 3, 'shears', 'sword' } 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
-- Insert breaking time header after block row when simple, or after tool or hardness row when not
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.foot or horizontal then
note = f:preprocess( '<references group="nota"/>' )
if args.foot == '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