Difference between revisions of "Module:Grid"

From Industrial-Craft-Wiki
Jump to navigation Jump to search
(Gonna try & see if this works for Module:Grid. If not, Chocohead will just yell at me :D)
(It worked, so I'm refining it a bit.)
 
(72 intermediate revisions by 3 users not shown)
Line 1: Line 1:
--<syntaxhighlight lang="lua">
local p = {}
local p = {}
-- Individual cell
-- Individual cell
function p.cell( f )
function p.grid(item)
local args = f.args or f
if f == mw.getCurrentFrame() and args[1] == nil then
    if (item == nil) then return { } end
args = f:getParent().args
end
    local iLink = nil
    local iFill = nil --[[for fluid_cell implementation]]
args[1] = mw.text.trim( args[1] or '' )
    local iNum= math.floor( string.match(item, ',%s*(%d+)' ) or 0 )
    local iName = string.sub(string.match(item, '.+,') or item..' ', 1, -2)
if not args.noalias then
    local tooltip = string.match(item, '%[.+%]')
-- Comment this next line out if you're not using aliases
    if tooltip ~= nil then
local aliases = mw.loadData( 'Module:Grid/Aliases' )
    iName = string.sub(iName, string.len(tooltip)+1)
    tooltip = string.sub(tooltip,2,-2)
local modAliases = args.modaliases or ''
    end
if modAliases ~= '' then
    local hasPercentage = string.match(item, "[%%]")
modAliases = mw.loadData( 'Module:' .. modAliases )
else
local aliases = mw.loadData('Module:Grid/Aliases')
modAliases = nil
if tooltip == nil then
end
if aliases[iName] then
tooltip = aliases[iName]
if aliases or modAliases then
local frames = {}
for frame in mw.text.gsplit( args[1], '%s*;%s*' ) do
local frameParts = p.getParts( frame, args.mod )
local id = frameParts.name
if frameParts.mod then
id = frameParts.mod .. ':' .. id
end
local alias
if modAliases and modAliases[id] then
alias = modAliases[id]
elseif aliases and aliases[id] then
alias = aliases[id]
end
if alias then
table.insert( frames, p.expandAlias( frameParts, alias ) )
else
table.insert( frames, frame )
end
end
args[1] = table.concat( frames, ';' )
end
end
end
local animated = args[1]:find( ';' )
local pageName = mw.title.getCurrentTitle().subpageText
local class = args.class or ''
local imgClass = args.imgclass or ''
local style = args.style or ''
local align = args.align or ''
local numStyle = args.numstyle or ''
local cell = {}
for frame in mw.text.gsplit( args[1], '%s*;%s*' ) do
if frame == '' then
if animated then
table.insert( cell, '<span class="item"><br></span>' )
else
table.insert( cell, '<br>' )
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 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 = 'Mods/' .. mod .. '/' .. name
else
link = name
end
end
local title = args.title or ''
if title == '' then
if tooltipTitle then
title = tooltipTitle:gsub( '&[0-9a-fk-or]', '' )
end
if mw.text.trim( title ) == '' or link:lower() == 'none' or link ~= name:gsub( '%s%(.*', '' ) then
title = name
end
end
if not tooltipTitle and title:lower() == 'none' then
tooltipTitle = 0
end
local alt = img
if title:lower() ~= 'none' then
alt = title
end
if link:lower() == 'none' then
link = ''
end
if title:lower() == 'none' then
title = ''
end
local tooltip = ''
if tooltipTitle then
tooltip = ' data-minetip-title="' .. tooltipTitle .. '"'
end
if tooltipDesc then
tooltip = tooltip .. ' data-minetip-text="' .. tooltipDesc .. '"'
end
local image = {
'<span class="item ' .. imgClass .. '" title="' .. title .. '"' .. tooltip .. '>',
'[[File:Grid ' .. img .. '.png|32x32px|link=' .. link .. '|alt=' .. alt .. ']]',
'</span>',
}
image[1] = image[1]:gsub( ' title=""', '' )
image[2] = image[2]:gsub( '||', '|' )
if num and num > 1 and num < 1000 then
if link ~= '' then
num = '[[' .. link .. '|' .. num .. ']]'
end
if numStyle ~= '' then
numStyle = ' style="' .. numStyle .. '"'
end
table.insert( image, 3, '<span class="number"' .. numStyle .. '>' .. num .. '</span>' )
end
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
local styles = {}
if align ~= '' then
table.insert( styles, 'vertical-align:' .. align )
end
if style ~= '' then
table.insert( styles, style )
end
if #styles > 0 then
styles = ' style="' .. table.concat( styles, ';' ) .. '"'
else
else
styles = ''
if aliases[tooltip] then
end
tooltip = aliases[tooltip]
local html = {
'<span class="grid ' .. class .. '"' .. styles .. '>',
table.concat( cell, '' ),
'</span>'
}
if ( args.default or '' ) ~= '' then
local defaultClass = ''
if animated then
defaultClass = ' skip'
end
end
table.insert( html, 2, '<span class="default-item' .. defaultClass .. '">[[File:Grid ' .. args.default .. '.png|32x32px|alt=|link=]]</span>' )
end
end
 
html = table.concat( html, '' ):gsub( ' "', '"' )
    if(iName:find("~")) then
return html
        iLink = string.match(iName, '~(.+)')
        iName = string.match(iName, '(.+)~')
    end
 
    if(iName:find("%^")) then
        local fhandler = mw.loadData('Module:Grid/FluidHandler')
        iFill = string.match(iName, '%^(.+)')
        iName = string.match(iName, '(.+)%^')
        if fhandler[iFill] then
          iFill = fhandler[iFill]  --[[rename]]
        else  --[[invalid fluid, so remove it]]
          iFill = nil
        end
        if fhandler[iName] then
          iName = fhandler[iName]  --[[rename]]
        else  --[[invalid container, so remove fluid]]
          iFill = nil
        end
    end
    paras = { }
    paras["name"] = iName
    if(iLink ~= nil) then paras["link"]=iLink end
    if(iFill ~= nil) then paras["fill"]=iFill end
    if(iNum > 1 or hasPercentage) then paras["number"]=iNum end
    if(hasPercentage) then paras["percent"]="x" end
    if(tooltip ~= nil) then paras["tooltip"]=tooltip end
   
    return paras
end
 
 
-- Gets a cell or animated cell
function p.cell(f, item)
    if (item == nil) then return '' end
    if (item:find(';')) then
        local text = '<div class=\"animated-grids\">'
        for frame in mw.text.gsplit( item, '%s*;%s*' ) do
            text = text .. '<span class=\"animated-grid\">'
            if frame == 'Blank' or frame == 'blank' then
              text = text .. ''
            else
              text = text .. f:expandTemplate{ title='Grid', args = p.grid(frame) }
            end
            text = text .. '</span>'
        end
        text = text .. '</div>'
        return text
    end
    return f:expandTemplate{ title='Grid', args = p.grid(item) }
end
 
--[[
function p.liquid(f, item)
    if (item == nil) then return '' end
    local text = ''
    for i=1,3,1 do
        text = text .. f:expandTemplate{ title='Grid', args = p.grid(item) }
    end
    return text
end
end
--]]


function p.expandAlias( frameParts, alias )
function p.tank(f)
-- If the frame has no parts, we can just return the alias as-is
local args = f
if not frameParts.title and not frameParts.mod and not frameParts.num and not frameParts.text then
if f == mw.getCurrentFrame() then
return alias
args = f:getParent().args
end
end
local link = args.link or ''
local expandedFrames = {}
local tank = args.tank or ''
for aliasFrame in mw.text.gsplit( alias, '%s*;%s*' ) do
local left = args.left or ''
local aliasParts = p.getParts( aliasFrame )
local width = args.width or '24'
aliasParts.title = frameParts.title or aliasParts.title or ''
local top = tonumber(args.top) or 92
aliasParts.mod = frameParts.mod or aliasParts.mod or 'Minecraft'
local height = tonumber(args.height) or 94
aliasParts.num = frameParts.num or aliasParts.num or ''
local max = tonumber(args.max) or 10000
aliasParts.text = frameParts.text or aliasParts.text or ''
local fill = tonumber(args.fill) or 0
if fill > max then
table.insert( expandedFrames, string.format( '[%s]%s:%s,%s[%s]', aliasParts.title, aliasParts.mod, aliasParts.name, aliasParts.num, aliasParts.text ) )
top = top - height
up = height
down = height * 2
else
top = top - ((height/max)*fill)
up = (height/max)*fill
down = height + ((height/max)*fill)
end
end
 
return table.concat( expandedFrames, ';' )
local div = mw.html.create('div')
div
:addClass('tooltip')
:css('left', left .. 'px')
:css('top', tostring(top) .. 'px')
:css('position', 'absolute')
:css('width', width .. 'px')
:css('height', tostring(height) .. 'px')
:css('clip', 'rect(' .. tostring(up) .. 'px,' .. tostring(width) ..'px,' .. tostring(down) .. 'px,0px)')
:attr('title', tank)
:wikitext('[[File:Tank ' .. tank .. '.png|' .. tostring(width) .. 'px|link=' .. link .. '|alt=]]')
return tostring( div )
end
end


function p.getParts( frame, mod )
 
local parts = {}
function p.gc ( f )
parts.title = frame:match( '^%[%s*([^%]]+)%s*%]' )
 
  local args = f
parts.mod = mw.text.trim( frame:match( '([^:%]]+):' ) or mod or '' )
 
  if f == mw.getCurrentFrame() then
local vanilla = { v = 1, vanilla = 1, mc = 1, minecraft = 1 }
      args = f:getParent().args
if parts.mod == '' or vanilla[mw.ustring.lower( parts.mod )] then
  end
parts.mod = nil
 
end
  return p.cell(f, (args[1] or args.name))
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
parts.text = frame:match( '%[%s*([^%]]+)%s*%]$' )
return parts
end
end


--- GUI variants; called directly to avoid the overhead of a bunch of #invoke calls per GUI
 
-- Crafting table
function p.craftingTable( f )
function p.craftingTable( f )
local args = f
    local args = f
if f == mw.getCurrentFrame() then
if f == mw.getCurrentFrame() then
args = f:getParent().args
args = f:getParent().args
end
end
local arrow = 'Arrow (small)'
    local gridArgs = {
local shapeless = ''
        A1=p.cell(f, args.A1),
if args.arrow or '' ~= '' then
        A2=p.cell(f, args.A2),
arrow = args.arrow .. ' (' .. args.Mod .. ')'
        A3=p.cell(f, args.A3),
end
if args.shapeless or '' ~= '' then
        B1=p.cell(f, args.B1),
shapeless = '<span title="This recipe is shapeless; the inputs may be placed in any arrangement in the crafting grid.">[[File:Grid layout Shapeless.png|link=]]</span>'
        B2=p.cell(f, args.B2),
elseif args.fixed or '' ~= '' then
        B3=p.cell(f, args.B3),
local notFixed = ''
if args.notfixed or '' ~= '' then
        C1=p.cell(f, args.C1),
notFixed = '; except for ' .. args.notfixed .. ', which can go anywhere'
        C2=p.cell(f, args.C2),
end
        C3=p.cell(f, args.C3),
shapeless = '<span title="This recipe is fixed, the input arrangement may not be moved or mirrored' .. notFixed .. '.">[[File:Grid layout Fixed.png|link=]]</span>'
end
        Output=p.cell(f, args.Output),
local html = {
        Break=args.Break
'{| 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 },
  return f:expandTemplate{ title='Crafting', args= gridArgs}
'| ' .. p.cell{ args.C1, mod = args.Mod, link = args.C1link, title = args.C1title },
'| rowspan="2" class="arrow" | [[File:Grid layout ' .. arrow .. '.png|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
end


-- Furnace
function p.furnace( f )
function p.furnace( f )
local args = f
if f == mw.getCurrentFrame() then
    local args = f
    if f == mw.getCurrentFrame() then
args = f:getParent().args
args = f:getParent().args
end
end
args = require( 'Module:ProcessArgs' ).norm( args )
    local gridArgs = {
local progress = 'Furnace Progress'
        Input=p.cell(f, (args.Input or args.Top)),
local burning = ' (in-active)'
        Fuel=p.cell(f, (args.Fuel or args.Bottom)),
local smelting = burning
        Output=p.cell(f, args.Output),
local fuelUsage = 'Fire'
        Break=args.Break
    }
if args.Progress then
progress = args.Progress .. ' Progress'
  return f:expandTemplate{ title='Crafting/Furnace', args= gridArgs}
if args.Mod then
progress = progress .. ' (' .. args.Mod .. ')'
end
end
 
function p.turningNumber(number)
if number == '1' then return 22
elseif number == '2' then return 44
elseif number == '3' then return 66
elseif number == '4' then return 88
else return 110
end
end
 
end
if args.Input and args.Fuel then
burning = ''
function p.turningBarrel(number,t)
if args.Output then
if t == nil then
smelting = ''
if number == '1' then return 38
elseif number == '2' then return 46
elseif number == '3' then return 52
elseif number == '4' then return 58
else return 64
end
end
end
else
if number == '1' then return 26
if args.FuelUsage then
elseif number == '2' then return 20
fuelUsage = args.FuelUsage
elseif number == '3' then return 14
if args.Mod then
elseif number == '4' then return 6
fuelUsage = fuelUsage .. ' (' .. args.Mod .. ')'
else return 0
end
end
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" | [[File:Grid layout ' .. progress .. smelting .. '.png|link=]]',
'| rowspan="3" class="output" | ' .. p.cell{ args.Output, mod = args.Mod, link = args.Olink, title = args.Otitle, class = 'output' },
'|-',
'| [[File:Grid layout ' .. fuelUsage .. burning .. '.png|link=]]',
'|-',
'| ' .. p.cell{ args.Fuel, mod = args.Mod, link = args.Flink, title = args.Ftitle },
'|}'
}
return table.concat( html, '\n' );
end
end
 
-- Brewing Stand
function p.turning(f)
function p.brewingStand( f )
local args = f
local args = f
if f == mw.getCurrentFrame() then
if f == mw.getCurrentFrame() then
args = f:getParent().args
args = f:getParent().args
end
end
args = require( 'Module:ProcessArgs' ).norm( args )
local gridArgs = {Output=p.cell(f, args.Output)}
if args.float or args.Float then gridArgs.float = args.float or args.Float end
if args.nobreak then gridArgs.nobreak = args.nobreak end
local inactive = ' (In-active)'
if args.Output == nil then return f:expandTemplate{title='Grid/Turning Table/Return', args=gridArgs} else gridArgs.Output = args.Output end
if args.Input and ( args.Output1 or args.Output2 or args.Output3 ) then
 
inactive = ''
local valid = {Drill='Iron', Handle='Iron', Axle='Iron', Wood='Wooden', Wooden='Wooden'}
if valid[args.Output] == nil then
return f:expandTemplate{title='Grid/Turning Table/Return', args=gridArgs}
else
gridArgs.Type = valid[args.Output]
end
 
if gridArgs.Type == 'Wooden' then
bounce = 3
else
bounce = 5
end
gridArgs.top = 70
if args.Layout ~= nil and args.Layout:find(',') then
local layout = mw.text.split(args.Layout,"%g*,%g*")
for i = 1, #layout do
if tonumber(layout[i]) > bounce then
layout[i] = tostring(bounce)
elseif tonumber(layout[i]) < 1 then
layout[i] = "1"
end
if tonumber(layout[i]) == 5 then
gridArgs.top = 71
end
end
gridArgs.n1 = p.turningNumber(layout[1])
gridArgs.b1 = p.turningBarrel(layout[1])
gridArgs.b1t = p.turningBarrel(layout[1],1)
gridArgs.n2 = p.turningNumber(layout[2])
gridArgs.b2 = p.turningBarrel(layout[2])
gridArgs.b2t = p.turningBarrel(layout[2],1)
gridArgs.n3 = p.turningNumber(layout[3] or bounce)
gridArgs.b3 = p.turningBarrel(layout[3] or bounce)
gridArgs.b3t = p.turningBarrel((layout[3] or bounce),1)
gridArgs.n4 = p.turningNumber(layout[4] or bounce)
gridArgs.b4 = p.turningBarrel(layout[4] or bounce)
gridArgs.b4t = p.turningBarrel((layout[4] or bounce),1)
gridArgs.n5 = p.turningNumber(layout[5] or bounce)
gridArgs.b5 = p.turningBarrel(layout[5] or bounce)
gridArgs.b5t = p.turningBarrel((layout[5] or bounce),1)
else
barrelbounce = p.turningBarrel(bounce)
barreltbounce = p.turningBarrel(bounce,1)
bounce = p.turningNumber(bounce)
gridArgs.n1 = bounce
gridArgs.b1 = barrelbounce
gridArgs.b1t = barreltbounce
gridArgs.n2 = bounce
gridArgs.b2 = barrelbounce
gridArgs.b2t = barreltbounce
gridArgs.n3 = bounce
gridArgs.b3 = barrelbounce
gridArgs.b3t = barreltbounce
gridArgs.n4 = bounce
gridArgs.b4 = barrelbounce
gridArgs.b4t = barreltbounce
gridArgs.n5 = bounce
gridArgs.b5 = barrelbounce
gridArgs.b5t = barreltbounce
end
end
local html = {
return f:expandTemplate{title='Grid/Turning Table/Return', args=gridArgs}
'<div class="grid-Brewing_Stand">',
'{| cellpadding="0" cellspacing="0"',
'| class="bubbles" | [[File:Grid layout Brewing Bubbles.gif|link=]]',
'| class="input" | ' .. p.cell{ args.Input, mod = args.Mod, link = args.Ilink, title = args.Ititle },
'| [[File:Grid layout Brewing Arrow' .. inactive .. '.png|link=]]',
'|-',
'| class="output1" | ' .. p.cell{ args.Output1, mod = args.Mod, link = args.O1link, title = args.O1title, default = 'layout Brewing Empty' },
'| class="output2" | ' .. p.cell{ args.Output2, mod = args.Mod, link = args.O2link, title = args.O2title, default = 'layout Brewing Empty' },
'| class="output3" | ' .. p.cell{ args.Output3, mod = args.Mod, link = args.O3link, title = args.O3title, default = 'layout Brewing Empty' },
'|-',
'| class="paths" colspan="3" | [[File:Grid layout Brewing Paths.png|link=]]',
'|}',
'</div>'
}
return table.concat( html, '\n' );
end
end
   
   
return p
return p
--</syntaxhighlight>

Latest revision as of 13:43, 13 December 2016

Template-info.png Documentation

This module is a WIP (work in progress), but is still being called by {{Grid/Crafting Table}}, so any changes should be tested to avoid inconvenience.

Related Links[edit]

The above documentation is transcluded from Module:Grid/doc. (edit | history)


--<syntaxhighlight lang="lua">
local p = {}
-- Individual cell
function p.grid(item)
 
    if (item == nil) then return { } end
 
    local iLink = nil
    local iFill = nil --[[for fluid_cell implementation]]
    local iNum= math.floor( string.match(item, ',%s*(%d+)' ) or 0 )
    local iName = string.sub(string.match(item, '.+,') or item..' ', 1, -2)
    local tooltip = string.match(item, '%[.+%]')
    if tooltip ~= nil then
    	iName = string.sub(iName, string.len(tooltip)+1)
    	tooltip = string.sub(tooltip,2,-2)
    end
    local hasPercentage = string.match(item, "[%%]")
 
	local aliases = mw.loadData('Module:Grid/Aliases')
	if tooltip == nil then
		if aliases[iName] then
			tooltip = aliases[iName]
		end
	else
		if aliases[tooltip] then
			tooltip = aliases[tooltip]
		end
	end

    if(iName:find("~")) then
        iLink = string.match(iName, '~(.+)')
        iName = string.match(iName, '(.+)~')
    end

    if(iName:find("%^")) then
        local fhandler = mw.loadData('Module:Grid/FluidHandler')
        iFill = string.match(iName, '%^(.+)')
        iName = string.match(iName, '(.+)%^')
        if fhandler[iFill] then
          iFill = fhandler[iFill]  --[[rename]]
        else  --[[invalid fluid, so remove it]]
          iFill = nil
        end
        if fhandler[iName] then
          iName = fhandler[iName]  --[[rename]]
        else  --[[invalid container, so remove fluid]]
          iFill = nil
        end
    end
 
    paras = { }
 
    paras["name"] = iName
 
    if(iLink ~= nil) then paras["link"]=iLink end
    if(iFill ~= nil) then paras["fill"]=iFill end
    if(iNum > 1 or hasPercentage) then paras["number"]=iNum end
    if(hasPercentage) then paras["percent"]="x" end
    if(tooltip ~= nil) then paras["tooltip"]=tooltip end
    
    return paras
 
end


-- Gets a cell or animated cell
function p.cell(f, item) 
 
    if (item == nil) then return '' end
 
    if (item:find(';')) then
        local text = '<div class=\"animated-grids\">'
 
 
        for frame in mw.text.gsplit( item, '%s*;%s*' ) do
 
            text = text .. '<span class=\"animated-grid\">'
            if frame == 'Blank' or frame == 'blank' then
               text = text .. ''
            else
               text = text .. f:expandTemplate{ title='Grid', args = p.grid(frame) }
            end
            text = text .. '</span>'
 
        end
 
        text = text .. '</div>'
 
        return text
    end
 
    return f:expandTemplate{ title='Grid', args = p.grid(item) }
end

--[[
function p.liquid(f, item) 
 
    if (item == nil) then return '' end
 
    local text = ''
 
    for i=1,3,1 do
        text = text .. f:expandTemplate{ title='Grid', args = p.grid(item) }
    end
 
    return text
end
--]]

function p.tank(f)
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	local link = args.link or ''
	local tank = args.tank or ''
	local left = args.left or ''
	local width = args.width or '24'
	local top = tonumber(args.top) or 92
	local height = tonumber(args.height) or 94
	local max = tonumber(args.max) or 10000
	local fill = tonumber(args.fill) or 0
	if fill > max then
		top = top - height
		up = height
		down = height * 2
	else
		top = top - ((height/max)*fill)
		up = (height/max)*fill
		down = height + ((height/max)*fill)
	end

	local div = mw.html.create('div')
	div
		:addClass('tooltip')
		:css('left', left .. 'px')
		:css('top', tostring(top) .. 'px')
		:css('position', 'absolute')
		:css('width', width .. 'px')
		:css('height', tostring(height) .. 'px')
		:css('clip', 'rect(' .. tostring(up) .. 'px,' .. tostring(width) ..'px,' .. tostring(down) .. 'px,0px)')
		:attr('title', tank)
		:wikitext('[[File:Tank ' .. tank .. '.png|' .. tostring(width) .. 'px|link=' .. link .. '|alt=]]')
	return tostring( div )
end


function p.gc ( f )

   local args = f

   if f == mw.getCurrentFrame() then
      args = f:getParent().args
   end

   return p.cell(f, (args[1] or args.name))
end


function p.craftingTable( f )
 
    local args = f
 
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
 
    local gridArgs = { 
 
        A1=p.cell(f, args.A1),
        A2=p.cell(f, args.A2),
        A3=p.cell(f, args.A3),
 
        B1=p.cell(f, args.B1),
        B2=p.cell(f, args.B2),
        B3=p.cell(f, args.B3),
 
        C1=p.cell(f, args.C1),
        C2=p.cell(f, args.C2),
        C3=p.cell(f, args.C3),
 
        Output=p.cell(f, args.Output),
 
        Break=args.Break
    }

   return f:expandTemplate{ title='Crafting', args= gridArgs}
 
end

function p.furnace( f )
 
    local args = f
 
    if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
 
    local gridArgs = { 
        Input=p.cell(f, (args.Input or args.Top)),
        Fuel=p.cell(f, (args.Fuel or args.Bottom)),
        Output=p.cell(f, args.Output),
        Break=args.Break
    }
 
   return f:expandTemplate{ title='Crafting/Furnace', args= gridArgs}
 
end
 

function p.turningNumber(number)
	if number == '1' then return 22
	elseif number == '2' then return 44
	elseif number == '3' then return 66
	elseif number == '4' then return 88
	else return 110
	end
end
 
function p.turningBarrel(number,t)
	if t == nil then
		if number == '1' then return 38
		elseif number == '2' then return 46
		elseif number == '3' then return 52
		elseif number == '4' then return 58
		else return 64
		end
	else
		if number == '1' then return 26
		elseif number == '2' then return 20
		elseif number == '3' then return 14
		elseif number == '4' then return 6
		else return 0
		end
	end
end
 
function p.turning(f)
	local args = f
	if f == mw.getCurrentFrame() then
		args = f:getParent().args
	end
	local gridArgs = {Output=p.cell(f, args.Output)}
	if args.float or args.Float then gridArgs.float = args.float or args.Float end
	if args.nobreak then gridArgs.nobreak = args.nobreak end
	
	if args.Output == nil then return f:expandTemplate{title='Grid/Turning Table/Return', args=gridArgs} else gridArgs.Output = args.Output end

	local valid = {Drill='Iron', Handle='Iron', Axle='Iron', Wood='Wooden', Wooden='Wooden'}
	if valid[args.Output] == nil then
		return f:expandTemplate{title='Grid/Turning Table/Return', args=gridArgs}
	else
		gridArgs.Type = valid[args.Output]
	end

	if gridArgs.Type == 'Wooden' then
		bounce = 3
	else
		bounce = 5
	end
	gridArgs.top = 70
	if args.Layout ~= nil and args.Layout:find(',') then
		local layout = mw.text.split(args.Layout,"%g*,%g*")
		for i = 1, #layout do
			if tonumber(layout[i]) > bounce then
				layout[i] = tostring(bounce)
			elseif tonumber(layout[i]) < 1 then
				layout[i] = "1"
			end
			if tonumber(layout[i]) == 5 then
				gridArgs.top = 71
			end
		end
		gridArgs.n1 = p.turningNumber(layout[1])
		gridArgs.b1 = p.turningBarrel(layout[1])
		gridArgs.b1t = p.turningBarrel(layout[1],1)
		gridArgs.n2 = p.turningNumber(layout[2])
		gridArgs.b2 = p.turningBarrel(layout[2])
		gridArgs.b2t = p.turningBarrel(layout[2],1)
		gridArgs.n3 = p.turningNumber(layout[3] or bounce)
		gridArgs.b3 = p.turningBarrel(layout[3] or bounce)
		gridArgs.b3t = p.turningBarrel((layout[3] or bounce),1)
		gridArgs.n4 = p.turningNumber(layout[4] or bounce)
		gridArgs.b4 = p.turningBarrel(layout[4] or bounce)
		gridArgs.b4t = p.turningBarrel((layout[4] or bounce),1)
		gridArgs.n5 = p.turningNumber(layout[5] or bounce)
		gridArgs.b5 = p.turningBarrel(layout[5] or bounce)
		gridArgs.b5t = p.turningBarrel((layout[5] or bounce),1)
	else
		barrelbounce = p.turningBarrel(bounce)
		barreltbounce = p.turningBarrel(bounce,1)
		bounce = p.turningNumber(bounce)
		gridArgs.n1 = bounce
		gridArgs.b1 = barrelbounce
		gridArgs.b1t = barreltbounce
		gridArgs.n2 = bounce
		gridArgs.b2 = barrelbounce
		gridArgs.b2t = barreltbounce
		gridArgs.n3 = bounce
		gridArgs.b3 = barrelbounce
		gridArgs.b3t = barreltbounce
		gridArgs.n4 = bounce
		gridArgs.b4 = barrelbounce
		gridArgs.b4t = barreltbounce
		gridArgs.n5 = bounce
		gridArgs.b5 = barrelbounce
		gridArgs.b5t = barreltbounce
	end
	
	return f:expandTemplate{title='Grid/Turning Table/Return', args=gridArgs}
end
 
return p
--</syntaxhighlight>