Diferencia entre revisiones de «Módulo:Brewing»
Sin resumen de edición |
Sin resumen de edición |
||
| (No se muestran 6 ediciones intermedias de 2 usuarios) | |||
| Línea 42: | Línea 42: | ||
local description = '' | local description = '' | ||
if args.showname == '1' or multirow and args.showname ~= '0' then | if args.showname == '1' or multirow and args.showname ~= '0' then | ||
name = ' | name = 'Nombre !! ' | ||
f:callParserFunction( '#dplvar:set', 'brewingname', '1' ) | f:callParserFunction( '#dplvar:set', 'brewingname', '1' ) | ||
end | end | ||
| Línea 57: | Línea 57: | ||
header = table.concat( { | header = table.concat( { | ||
'{| class="wikitable ' .. class .. '"', | '{| class="wikitable ' .. class .. '"', | ||
'! ' .. name .. ' | '! ' .. name .. 'Ingredientes !! ' .. recipeClass .. ' Receta de [[Alquimia]]' .. description, | ||
'|-' | '|-' | ||
}, '\n' ) | }, '\n' ) | ||
| Línea 66: | Línea 66: | ||
local base = args.base or '' | local base = args.base or '' | ||
if base == '' then | if base == '' then | ||
base = 'Poción | base = 'Poción rara' | ||
end | end | ||
| Línea 97: | Línea 97: | ||
if nameCell and args.upcoming == '1' then | if nameCell and args.upcoming == '1' then | ||
nameCell = nameCell .. '<br>( | nameCell = nameCell .. '<br>(próximamente)' | ||
end | end | ||
| Línea 184: | Línea 184: | ||
local category = '' | local category = '' | ||
if mw.title.getCurrentTitle().namespace == 0 and args.nocat ~= '1' and args.upcoming == '1' then | if mw.title.getCurrentTitle().namespace == 0 and args.nocat ~= '1' and args.upcoming == '1' then | ||
category = '[[ | category = '[[Categoría:Próximamente]]' | ||
end | end | ||
Revisión actual - 17:37 13 ago 2015
local p = {}
function p.table( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local grid = require( 'Module:Grid' )
-- Start table when appropriate local multirow = f:callParserFunction( '#dplvar', 'multirow' ) if multirow ~= '1' then multirow = nil end local head = args.head or if multirow then head = elseif head ~= then multirow = 1 f:callParserFunction( '#dplvar:set', 'multirow', '1' ) else head = 1 end
-- End table when appropriate local foot = args.foot or if multirow then if foot ~= then multirow = nil f:callParserFunction( '#dplvar:set', 'multirow', '0' ) end else foot = 1 end
local header = if head ~= then local name = local description =
if args.showname == '1' or multirow and args.showname ~= '0' then
name = 'Nombre !! ' f:callParserFunction( '#dplvar:set', 'brewingname', '1' ) end if args.showdescription == '1' then description = ' !! class="unsortable" | Description' f:callParserFunction( '#dplvar:set', 'brewingdescription', '1' ) end local class = args.class or local recipeClass = if multirow then class = 'sortable collapsible ' .. class recipeClass = 'class="unsortable collapse-button" |' end header = table.concat( { '{| class="wikitable ' .. class .. '"', '! ' .. name .. 'Ingredientes !! ' .. recipeClass .. ' Receta de Alquimia' .. description, '|-' }, '\n' ) end
local input = mw.text.trim( args[1] or ) local output2 = mw.text.trim( args[2] or )
local base = args.base or
if base == then base = 'Poción rara' end
-- Name cell local nameCell if args.name or ~= then nameCell = args.name elseif multirow or f:callParserFunction( '#dplvar', 'brewingname' ) == '1' then local names = {} local links = {} for v in mw.text.gsplit( args[2] or , '%s*;%s*' ) do parts = grid.getParts( v ) if not names[( parts.mod or ) .. parts.name] then local link = if parts.mod then link = 'Mods/' .. parts.mod .. '/' .. parts.name .. '|' end
if parts.name:find( '^Any ' ) then table.insert( links, 'Any ' .. link .. parts.name:sub( 4 ) .. '' ) else table.insert( links, '' .. link .. parts.name .. '' ) end names[( parts.mod or ) .. parts.name] = 1 end end
nameCell = table.concat( links, ' or
' )
end
if nameCell and args.upcoming == '1' then
nameCell = nameCell .. '
(próximamente)'
end
-- Ingredients cell
local ingredientsCell
if args.ingredients or ~= then
ingredientsCell = args.ingredients
else
ingredientsCell = {}
local ingredients = {}
for k, v in ipairs{ input, base } do
local separator =
if k == 2 and next( ingredients ) then
separator = ' +
\n'
end
for item in mw.text.gsplit( v, '%s*;%s*' ) do
local parts = grid.getParts( item )
if parts.name ~= and not ingredients[parts.name] and ( k == 2 or k == 1 and v ~= base ) then
local link =
if separator == and next( ingredients ) then
separator = ' or
\n'
end
if parts.mod then link = 'Mods/'.. parts.mod .. '/' .. parts.name .. '|' end
if parts.name:find( '^Any ' ) then table.insert( ingredientsCell, separator .. 'Any ' .. link .. parts.name:sub( 4 ) .. '' ) else table.insert( ingredientsCell, separator .. '' .. link .. parts.name .. '' ) end separator =
ingredients[parts.name] = 1 end end end
ingredientsCell = table.concat( ingredientsCell ) end
-- Whether to show base or output local newArgs = {} if args.showbase == '1' then
newArgs.Output2 = base
newArgs.Output1 = args.base2 newArgs.Output3 = args.base3 else
newArgs.Output2 = args[2]
newArgs.Output1 = args[3] newArgs.Output3 = args[4] end
-- Any other args we want to pass along
newArgs.Input = args[1] newArgs.Ititle = args.Ititle newArgs.O2title = args.Otitle newArgs.O1title = args.O2title newArgs.O3title = args.O3title
-- Recipe cell local recipeCell = grid.brewingStand( newArgs )
local row = { ingredientsCell, recipeCell } if nameCell then table.insert( row, 1, nameCell ) end if ( args.description or ) ~= and f:callParserFunction( '#dplvar', 'brewingdescription' ) == '1' then table.insert( row, args.description ) end row = table.concat( row, '\n|\n' )
if nameCell then row = '!\n' .. row else row = '|\n' .. row end
local footer = if foot ~= then footer = '|}' f:callParserFunction( '#dplvar:set', 'brewingname', '0', 'brewingdescription', '0' ) end
local category = if mw.title.getCurrentTitle().namespace == 0 and args.nocat ~= '1' and args.upcoming == '1' then category = end
return header .. '\n' .. row .. '\n|-\n' .. footer .. category end return p