FANDOM


local p = {}

-- Individual cell function p.cell( f ) local args = f.args or f if f == mw.getCurrentFrame() and args[1] == nil then args = f:getParent().args end

args[1] = mw.text.trim( args[1] or )

-- Comment this next line out if you're not using aliases local aliases = mw.loadData( 'Modul:Grid/Aliases' ) if aliases then local frames = {} for frame in mw.text.gsplit( args[1], '%s*;%s*' ) do local frameParts = p.getParts( frame ) if aliases[frameParts.name] then local aliasFrames = {} for aliasFrame in mw.text.gsplit( aliases[frameParts.name], '%s*;%s*' ) do local aliasParts = p.getParts( aliasFrame ) aliasParts.title = frameParts.title or aliasParts.title or aliasParts.mod = frameParts.mod or aliasParts.mod or 'vanilla' aliasParts.num = frameParts.num or aliasParts.num or aliasParts.text = frameParts.text or aliasParts.text or aliasParts.damage = ( frameParts.damage >= 0 and tostring( frameParts.damage ) ) or ( aliasParts.damage >= 0 and tostring( aliasParts.damage ) ) or aliasParts.enchanted = frameParts.enchanted and 'e' or aliasParts.enchanted and 'e' or

aliasFrames[#aliasFrames + 1] = string.format( '[%s]%s:%s,%s#%s%s[%s]', aliasParts.title, aliasParts.mod, aliasParts.name, aliasParts.num, aliasParts.damage, aliasParts.enchanted, aliasParts.text ) end

frames[#frames + 1] = table.concat( aliasFrames, ';' ) else frames[#frames + 1] = frame end end

args[1] = table.concat( frames, ';' ) end

local animated = args[1]:find( ';' ) local pageName = mw.title.getCurrentTitle().subpageText local class = args.class or local imgClass = args.imgclass or local align = args.align or local cell = {}

for frame in mw.text.gsplit( args[1], '%s*;%s*' ) do if frame == then if animated then table.insert( cell, '
' ) else table.insert( cell, '
' ) end else local parts = p.getParts( frame, args.mod ) local tooltipTitle = parts.title local mod = parts.mod local name = parts.name local num = parts.num local tooltipDesc = parts.text local damage = args.damage or parts.damage local enchanted = ( args.enchanted == nil and parts.enchanted ) or args.enchanted

local img if mod then img = name .. ' (' .. mod .. ')' else img = name end

local link = args.link or if link == then if name == pageName then link = 'none' elseif mod then link = 'Modifikation/' .. mod else link = name end end

if not tooltipTitle and enchanted then tooltipTitle = '&b' .. name:gsub( '%s%(.*', ) end

local title = args.title or if title == then if tooltipTitle then title = tooltipTitle:gsub( '&[0-9a-fk-or]', ) elseif link:lower() == 'none' or link ~= name:gsub( '%s%(.*', ) then title = name:gsub( '%s%(.*', ) end end

local tooltip = if not tooltipTitle and title:lower() == 'none' then tooltipTitle = 0 end

local alt = img if title:lower() ~= 'none' then alt = title end if mod then alt = mod .. ':' .. alt end

if link:lower() == 'none' then link = end if title:lower() == 'none' then title = end if mod then title = mod .. ':' .. title end

if tooltipTitle then tooltip = ' data-minetip-title="' .. tooltipTitle .. '"' end

if tooltipDesc then tooltip = tooltip .. ' data-minetip-text="' .. tooltipDesc .. '"' end

local amount = if num and num > 1 and num < 1000 then if link ~= then num = '' .. num .. '' end amount = '' .. num .. '' end

local pClass = if tonumber( damage ) >= 0 then pClass = 'damaged damage-' .. tostring( damage ) .. ' ' end

if enchanted then pClass = pClass .. 'enchanted ' end

local image = { '', '32x32px|link=' .. link .. '|alt=' .. alt .. '', amount, '' } image[1] = image[1]:gsub( ' title=""', ) image[2] = image[2]:gsub( '||', '|' )

table.insert( cell, table.concat( image, ) ) end end

if animated then cell[1] = cell[1]:gsub( 'class="item', 'class="item active' ) class = 'animated ' .. class end

if align ~= then align = ' style="vertical-align:' .. align .. '"' end

local html = { '', table.concat( cell, ), '' }

if ( args.default or ) ~= then local defaultClass = if animated then defaultClass = ' skip' end table.insert( html, 2, '32x32px|alt=|link=' ) end

html = table.concat( html, ):gsub( ' "', '"' ) return html end

function p.getParts( frame, mod ) local parts = {} parts.title = frame:match( '^%[%s*([^%]]+)%s*%]' )

parts.mod = mw.text.trim( frame:match( '([^:%]]+):' ) or mod or )

local vanilla = { v = 1, vanilla = 1, mc = 1, minecraft = 1 } if parts.mod == or vanilla[parts.mod:lower()] then parts.mod = nil end

local nameStart = ( frame:find( ':' ) or frame:find( '%]' ) or 0 ) + 1 if nameStart - 1 == #frame then nameStart = 1 end parts.name = mw.text.trim( frame:sub( nameStart, ( frame:find( '[,%[#]', nameStart ) or 0 ) - 1 ) )

parts.num = math.floor( frame:match( ',%s*(%d+)' ) or 0 ) if parts.num == 0 then parts.num = nil end

local parameters = { frame:match( '#%s*(%d?)%s*(e?)' ) }

parts.damage = -1 if ( parameters[1] ~= nil and parameters[1] ~= ) then parts.damage = tonumber( parameters[1] ) end

parts.enchanted = parameters[2] == 'e'

parts.text = frame:match( '%[%s*([^%]]+)%s*%]$' )

return parts end

function p.serialize( parts ) local frame =

if ( parts.title ~= nil and parts.title ~= parts.name and parts.title ~= ) then frame = frame .. '[' .. parts.title .. ']' end

if ( parts.mod ~= nil and parts.mod ~= ) then frame = frame .. parts.mod .. ':' end

if parts.name ~= nil then frame = frame .. parts.name end

if ( parts.num ~= nil and parts.num ~= 0 ) then frame = frame .. ',' .. tostring( parts.num ) end

if ( parts.damage ~= nil and parts.damage >= 0 ) or ( parts.enchanted ~= nil and parts.enchanted ) then frame = frame .. '#' end

if ( parts.damage ~= nil and parts.damage >= 0 ) then frame = frame .. tostring( parts.damage ) end

if ( parts.enchanted ~= nil and parts.enchanted ) then frame = frame .. 'e' end

if ( parts.text ~= nil and parts.text ~= ) then frame = frame .. '[' .. parts.text .. ']' end

return frame end

--- GUI variants; called directly to avoid the overhead of a bunch of #invoke calls per GUI -- Crafting table function p.craftingTable( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args end

local arrow = 'Pfeil (klein)' local shapeless = local mirror =

if args.arrow or ~= then arrow = args.arrow .. ' (' .. args.Mod .. ')' end if args.shapeless or ~= then shapeless = 'link=' end if args.mirror or ~= then shapeless = 'link=' end

local html = { '{| class="grid-Crafting_Table" cellpadding="0" cellspacing="0"', '| ' .. p.cell{ args.A1, mod = args.Mod, link = args.A1link, title = args.A1title }, '| ' .. p.cell{ args.B1, mod = args.Mod, link = args.B1link, title = args.B1title }, '| ' .. p.cell{ args.C1, mod = args.Mod, link = args.C1link, title = args.C1title }, '| rowspan="2" class="arrow" | link=', '| rowspan="3" | ' .. p.cell{ args.Output, mod = args.Mod, link = args.Olink, title = args.Otitle, class = 'output' }, '|-', '| ' .. p.cell{ args.A2, mod = args.Mod, link = args.A2link, title = args.A2title }, '| ' .. p.cell{ args.B2, mod = args.Mod, link = args.B2link, title = args.B2title }, '| ' .. p.cell{ args.C2, mod = args.Mod, link = args.C2link, title = args.C2title }, '|-', '| ' .. p.cell{ args.A3, mod = args.Mod, link = args.A3link, title = args.A3title }, '| ' .. p.cell{ args.B3, mod = args.Mod, link = args.B3link, title = args.B3title }, '| ' .. p.cell{ args.C3, mod = args.Mod, link = args.C3link, title = args.C3title }, '| class="shapeless" | ' .. shapeless, '|}' }

return table.concat( html, '\n' ); end

-- Furnace function p.furnace( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args end args = require( 'Modul:ParameterUmwandeln' ).norm( args )

local progress = 'Ofenfortschritt' local burning = ' (inaktiv)' local smelting = burning local fuelUsage = 'Feuer'

if args.Progress then progress = args.Progress .. ' Progress' if args.Mod then progress = progress .. ' (' .. args.Mod .. ')' end end

if args.Input and args.Fuel then burning = if args.Output then smelting = end end

if args.FuelUsage then fuelUsage = args.FuelUsage if args.Mod then fuelUsage = fuelUsage .. ' (' .. args.Mod .. ')' end end

local html = { '{| class="grid-Furnace" cellpadding="0" cellspacing="0"', '| ' .. p.cell{ args.Input, mod = args.Mod, link = args.Ilink, title = args.Ititle }, '| rowspan="3" class="arrow" | link=', '| rowspan="3" class="output" | ' .. p.cell{ args.Output, mod = args.Mod, link = args.Olink, title = args.Otitle, class = 'output' }, '|-', '| link=', '|-', '| ' .. p.cell{ args.Fuel, mod = args.Mod, link = args.Flink, title = args.Ftitle }, '|}' }

return table.concat( html, '\n' ); end

-- Furnace (RedPower2) function p.furnace_rp2( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args end args = require( 'Modul:ParameterUmwandeln' ).norm( args )

local progress = 'Ofenfortschritt' local burning = ' (inaktiv)' local smelting = burning local fuelUsage = 'Feuer' local shapeless =

if args.Progress then progress = args.Progress .. ' Progress' if args.Mod then progress = progress .. ' (' .. args.Mod .. ')' end end

if args.Input and args.Fuel then burning = if args.Output then smelting = end end

if args.FuelUsage then fuelUsage = args.FuelUsage if args.Mod then fuelUsage = fuelUsage .. ' (' .. args.Mod .. ')' end end

if args.shapeless or ~= then shapeless = 'link=' end

local html = { '{| class="grid-Furnace" cellpadding="0" cellspacing="0"', '| ', '| style="width:16px;" |', '| ' .. p.cell{ args.A1, mod = args.Mod, link = args.A1link, title = args.A1title }, '| ' .. p.cell{ args.B1, mod = args.Mod, link = args.B1link, title = args.B1title }, '| ' .. p.cell{ args.C1, mod = args.Mod, link = args.C1link, title = args.C1title }, '| rowspan="3" class="arrow" | link=', '| rowspan="3" class="output" | ' .. p.cell{ args.Output, mod = args.Mod, link = args.Olink, title = args.Otitle, class = 'output' }, '|-', '| link=', '| ', '| ' .. p.cell{ args.A2, mod = args.Mod, link = args.A2link, title = args.A2title }, '| ' .. p.cell{ args.B2, mod = args.Mod, link = args.B2link, title = args.B2title }, '| ' .. p.cell{ args.C2, mod = args.Mod, link = args.C2link, title = args.C2title }, '|-', '| ' .. p.cell{ args.Fuel, mod = args.Mod, link = args.Flink, title = args.Ftitle }, '| ', '| ' .. p.cell{ args.A3, mod = args.Mod, link = args.A3link, title = args.A3title }, '| ' .. p.cell{ args.B3, mod = args.Mod, link = args.B3link, title = args.B3title }, '| ' .. p.cell{ args.C3, mod = args.Mod, link = args.C3link, title = args.C3title }, '| class="shapeless" | ' .. shapeless, '|}' }

return table.concat( html, '\n' ); end

-- Brewing Stand function p.brewingStand( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args end args = require( 'Modul:ParameterUmwandeln' ).norm( args )

local inactive = ' (inaktiv)' if args.Input and ( args.Output1 or args.Output2 or args.Output3 ) then inactive = end

local html = {

'
',

'{| cellpadding="0" cellspacing="0"', '| class="fuel" | ' .. p.cell{ ';Lohenstaub', link=,default='Layout Lohenstaub leer' }, '| class="coil" | link=', '| class="bubbles" | link=
link=', '| class="input" | ' .. p.cell{ args.Input, mod = args.Mod, link = args.Ilink, title = args.Ititle }, '| link=', '|-', '| ', '| ', '| class="output1" | ' .. p.cell{ args.Output1, mod = args.Mod, link = args.O1link, title = args.O1title, default = 'Layout Brauen (leer)' }, '| class="output2" | ' .. p.cell{ args.Output2, mod = args.Mod, link = args.O2link, title = args.O2title, default = 'Layout Brauen (leer)' }, '| class="output3" | ' .. p.cell{ args.Output3, mod = args.Mod, link = args.O3link, title = args.O3title, default = 'Layout Brauen (leer)' }, '|-', '| ', '| ', '| class="paths" colspan="3" | link=', '|}',

'
'

}

return table.concat( html, '\n' ); end

function p.anvil( f ) local args = f if f == mw.getCurrentFrame() then args = f:getParent().args end args = require( 'Modul:ParameterUmwandeln' ).norm( args )

local working = '(erlaubt)' local xp = ' ' local color = 'limegreen' local dark = ' (dunkel)'

local aliases = mw.loadData( 'Modul:Grid/Aliases' )

local inputFrames = {} if args.input ~= nil then inputFrames = mw.text.split( args.input, '%s*;%s*' ) end

local titleFrames = {} if args.title ~= nil then titleFrames = mw.text.split( args.title, '%s*;%s*' ) end

local levelFrames = {} if args.level ~= nil then levelFrames = mw.text.split( args.level, '%s*;%s*' ) end

local victimFrames = {} if args.victim ~= nil then victimFrames = mw.text.split( args.victim, '%s*;%s*' ) end

local outputFrames = {} if args.output ~= nil then outputFrames = mw.text.split( args.output, '%s*;%s*' ) end

if args.input then dark = -- Heller Balken mit Itemname sobald ein Item im ersten Slot ist

function smod( a, b ) return ( a - 1 ) % b + 1 end

if args.debug then -- Expand aliases local newInputFrames, newTitleFrames, newLevelFrames, newVictimFrames, newOutputFrames = {}, {}, {}, {}, {}

for i = 1, #inputFrames do local inputParts = p.getParts( inputFrames[i] ) local inputFrame = ( aliases and aliases[inputParts.name] ) or inputFrames[i] local inputAliasFrames = mw.text.split( inputFrame, '%s*;%s*' )

local victimParts, victimFrame, victimAliasFrames if victimFrames[smod( i, #victimFrames )] ~= nil then victimParts = p.getParts( victimFrames[smod( i, #victimFrames )] ) victimFrame = ( aliases and aliases[victimParts.name] ) or victimFrames[smod( i, #victimFrames )] victimAliasFrames = mw.text.split( victimFrame, '%s*;%s*' ) end

local outputParts, outputFrame, outputAliasFrames if outputFrames[smod( i, #outputFrames )] ~= nil then outputParts = p.getParts( outputFrames[smod( i, #outputFrames )] ) outputFrame = ( aliases and aliases[outputParts.name] ) or outputFrames[smod( i, #outputFrames )] outputAliasFrames = mw.text.split( outputFrame, '%s*;%s*' ) end

local inputStr, titleStr, levelStr, victimStr, outputStr = , , , ,

for j = 1, #inputAliasFrames do local k1 if victimAliasFrames ~= nil then k1 = ( j - 1 ) % #victimAliasFrames + 1 end

local k2 if outputAliasFrames ~= nil then k2 = ( j - 1 ) % #outputAliasFrames + 1 end

local tempInputParts = inputParts tempInputParts.name = inputAliasFrames[j] if inputStr ~= then inputStr = inputStr .. ';' end inputStr = inputStr .. p.serialize( tempInputParts )

if ( victimAliasFrames ~= nil and victimAliasFrames[k1] ~= nil ) then local tempVictimParts = victimParts tempVictimParts.name = victimAliasFrames[k1] if victimStr ~= then victimStr = victimStr .. ';' end victimStr = victimStr .. p.serialize( tempVictimParts ) end

if ( outputAliasFrames ~= nil and outputAliasFrames[k2] ~= nil ) then local tempOutputParts = outputParts tempOutputParts.name = outputAliasFrames[k2] if outputStr ~= then outputStr = outputStr .. ';' end outputStr = outputStr .. p.serialize( tempOutputParts ) end

if titleFrames[( i - 1 ) % #titleFrames + 1] ~= nil then if titleStr ~= then titleStr = titleStr .. ';' end titleStr = titleStr .. titleFrames[( i - 1 ) % #titleFrames + 1] end

if levelFrames[( i - 1 ) % #levelFrames + 1] ~= nil then if levelStr ~= then levelStr = levelStr .. ';' end levelStr = levelStr .. levelFrames[( i - 1 ) % #levelFrames + 1] end end

newInputFrames[i] = inputStr newTitleFrames[i] = titleStr newLevelFrames[i] = levelStr newVictimFrames[i] = victimStr newOutputFrames[i] = outputStr end

inputFrames = newInputFrames titleFrames = newTitleFrames levelFrames = newLevelFrames victimrames = newVictimrames outputFrames = newOutputFrames

inputFrames = mw.text.split( table.concat( inputFrames, ';' ), '%s*;%s*' ) if #victimFrames > 0 then titleFrames = mw.text.split( table.concat( titleFrames, ';' ), '%s*;%s*' ) end if #victimFrames > 0 then levelFrames = mw.text.split( table.concat( levelFrames, ';' ), '%s*;%s*' ) end if #victimFrames > 0 then victimFrames = mw.text.split( table.concat( victimFrames, ';' ), '%s*;%s*' ) end if #outputFrames > 0 then outputFrames = mw.text.split( table.concat( outputFrames, ';' ), '%s*;%s*' ) end

if args.debug == 'return' then return ';input\n* ' .. table.concat( inputFrames, '\n* ' ) .. '\n;title\n* ' .. table.concat( titleFrames, '\n* ' ) .. '\n;level\n* ' .. table.concat( levelFrames, '\n* ' ) .. '\n;victim\n* ' .. table.concat( victimFrames, '\n* ' ) .. '\n;output\n* ' .. table.concat( outputFrames, '\n* ' ) end end

for i = 1, #inputFrames do local frame = inputFrames[i] local inputParts = p.getParts( frame )

local frameTitle = inputParts.name if ( not args.debug and aliases and aliases[frameTitle] ~= nil ) then local aliasParts = p.getParts( aliases[frameTitle] )

if aliasParts.title ~= nil then frameTitle = aliasParts.title elseif aliasParts.name ~= nil then frameTitle = aliasParts.name end end

if ( args.title == nil and titleFrames[i] == nil ) then titleFrames[i] = frameTitle:gsub( '&[0-9a-fk-or]', ) elseif ( titleFrames[i] == nil ) then titleFrames[i] = titleFrames[1] end

if levelFrames[i] == nil then levelFrames[i] = levelFrames[( i - 1 ) % #levelFrames + 1] end

if victimFrames[i] == nil then victimFrames[i] = victimFrames[( i - 1 ) % #victimFrames + 1] end

local outputParts = inputParts if outputFrames[i] ~= nil then outputParts = p.getParts( outputFrames[i] ) end if titleFrames[i] ~= nil then outputParts.title = titleFrames[i] end

if victimFrames[i] ~= nil then if ( outputFrames[i] == nil or ( outputFrames[i] ~= nil and p.getParts( outputFrames[i] ).damage == nil ) ) then outputParts.damage = -1 end

local victimParts = p.getParts( victimFrames[i] )

if victimParts.enchanted ~= nil then outputParts.enchanted = outputParts.enchanted or victimParts.enchanted if ( outputParts.title ~= nil and outputParts.enchanted ) then outputParts.title = '&b' .. outputParts.title:gsub( '^(&b)+', ) end end if victimParts.text ~= nil then outputParts.text = outputParts.text or victimParts.text end

if ( not args.debug and aliases and aliases[victimParts.name] ~= nil ) then local aliasParts = p.getParts( aliases[victimParts.name] )

if aliasParts.enchanted ~= nil then outputParts.enchanted = outputParts.enchanted or aliasParts.enchanted if outputParts.title ~= nil then outputParts.title = '&b' .. outputParts.title end end if aliasParts.text ~= nil then outputParts.text = outputParts.text or aliasParts.text end end end

outputFrames[i] = p.serialize( outputParts ) end

if #titleFrames > #inputFrames then for i = #inputFrames + 1, #titleFrames do titleFrames[i] = nil end end if #levelFrames > #inputFrames then for i = #inputFrames + 1, #levelFrames do levelFrames[i] = nil end end if #victimFrames > #inputFrames then for i = #inputFrames + 1, #victimFrames do victimFrames[i] = nil end end if #outputFrames > #inputFrames then for i = #inputFrames + 1, #outputFrames do outputFrames[i] = nil end end else titleFrames = {} victimFrames = {} outputFrames = {} end

if args.locked ~= nil then outputFrames = {} end

local input = table.concat( inputFrames, ';' ) local victim = table.concat( victimFrames, ';' ) local output = table.concat( outputFrames, ';' )

if args.debug ~= nil then return '\n;Input\n* ' .. table.concat( inputFrames, '\n* ' ) .. '' .. '\n;Title\n* ' .. table.concat( titleFrames, '\n* ' ) .. '' .. '\n;Level\n* ' .. table.concat( levelFrames, '\n* ' ) .. '' .. '\n;Victim\n* ' .. table.concat( victimFrames, '\n* ' ) .. '' .. '\n;Output\n* ' .. table.concat( outputFrames, '\n* ' ) .. '' end

-- Schriftfarbe der Erfahrungskosten auf Rot, wenn bei rot irgendwas angegeben if args.red then color = 'red' end

--Animation für den Namen local title = {} if #titleFrames > 0 then for i,t in pairs( titleFrames ) do if t == then table.insert( title, '
' ) else table.insert( title, '' .. t .. '' ) end end title[1] = title[1]:gsub( '^', '' ) end

--Animation für mehrere Level local level = {}

-- Wenn bei gesperrt teuer angegeben ist, ist die Reparatur zu teuer if args.locked == 'expensive' then color = 'red' xp = 'Zu teuer!' working = '(gesperrt)' level = {} elseif args.locked then -- wenn irgendwas (außer expensive) bei locked angegeben ist, ist der Vorgang nicht möglich color = xp = ' ' working = '(gesperrt)' level = {} elseif #levelFrames > 0 then -- Anzeige der Erfahrungskosten, wenn level angegeben xp = 'Erfahrungskosten: '

for i,l in pairs( levelFrames ) do if l == then table.insert( level, '
' ) else table.insert( level, '' .. l .. '' ) end end level[1] = level[1]:gsub( '^', '' ) end

--Die Tabelle local html = { '{| class="grid-Furnace" cellpadding="0" cellspacing="0" style="width:370px"', '| 64px|link=

',

'| align="right" colspan="5" |
' .. table.concat( title ) .. '
220x32px|link=
 ',

'|-', '|      ' .. p.cell{ input }, '|    30px|link=   ', '|    ' .. p.cell{ victim }, '|    56x42px|link=', '|    ' .. p.cell{ output }, '|         ', '|-',

'| align="right" colspan="6" |
' .. xp .. table.concat( level ) .. '
',

'|}' }

return table.concat( html, '\n' ); end

return p

Community content is available under CC-BY-SA unless otherwise noted.