Module:UI: Difference between revisions
Jump to navigation
Jump to search
Create: Minecraft Mod Wiki>Joker876 No edit summary |
BoxWithout (talk | contribs) m 129 revisions imported |
||
(66 intermediate revisions by 3 users not shown) | |||
Line 186: | Line 186: | ||
) | ) | ||
end | end | ||
arrow:wikitext(addSlot(args, 'Output', '', 'invslot-plain mcui-stonecutterSprite')) | arrow:wikitext(addSlot(args, 'Output', '', 'invslot-plain invslot-noformat mcui-stonecutterSprite')) | ||
body | body | ||
Line 192: | Line 192: | ||
:addClass('mcui-output') | :addClass('mcui-output') | ||
:wikitext(addSlot(args, 'Output', 'O', 'invslot-large')) | :wikitext(addSlot(args, 'Output', 'O', 'invslot-large')) | ||
return tostring(mw.html.create('div'):node(body)) | |||
end | |||
-- Pre-1.20 Smithing Table | |||
function p.legacySmithing(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
local body = mw.html.create('span'):addClass('mcui mcui-legacySmithing pixel-image') | |||
body:tag('span'):addClass('mcui-text'):wikitext('Upgrade Gear'):done() | |||
body:tag('span'):addClass('mcui-smithingHammer'):tag('br'):done() | |||
local bottom = body:tag('div'):addClass('mcui-bottom') | |||
local input = bottom:tag('span'):addClass('mcui-input') | |||
input:wikitext(addSlot(args, 'Input1', 'I1')) | |||
input:tag('span'):addClass('mcui-plus'):done() | |||
input:wikitext(addSlot(args, 'Input2', 'I2')) | |||
bottom:tag('span'):addClass('mcui-arrow'):tag('br'):done() | |||
bottom | |||
:tag('span') | |||
:addClass('mcui-output') | |||
:wikitext(addSlot(args, 'Output', 'O')) | |||
return tostring(mw.html.create('div'):node(body)) | |||
end | |||
-- Post-1.20 Smithing Table | |||
function p.smithingTable(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
local body = mw.html.create('span'):addClass('mcui mcui-smithingTable pixel-image') | |||
body:tag('span'):addClass('mcui-text'):wikitext('Upgrade Gear'):done() | |||
body:tag('span'):addClass('mcui-smithingHammer'):tag('br'):done() | |||
local bottom = body:tag('div'):addClass('mcui-bottom') | |||
local input = bottom:tag('span'):addClass('mcui-input') | |||
input:wikitext(addSlot(args, 'Input1', 'I1')) | |||
input:wikitext(addSlot(args, 'Input2', 'I2')) | |||
input:wikitext(addSlot(args, 'Input3', 'I3')) | |||
bottom:tag('span'):addClass('mcui-arrow'):tag('br'):done() | |||
bottom | |||
:tag('span') | |||
:addClass('mcui-output') | |||
:wikitext(addSlot(args, 'Output', 'O')) | |||
return tostring(mw.html.create('div'):node(body)) | return tostring(mw.html.create('div'):node(body)) | ||
Line 288: | Line 350: | ||
f = mw.getCurrentFrame() | f = mw.getCurrentFrame() | ||
end | end | ||
return p.commonMachine{ | |||
args, | |||
manyInputs=false, | |||
manyOutputs=true, | |||
allowChance=true, | |||
slot='Crushing', | |||
paddingtop = '14px', | |||
paddingtop2 = '14px' | |||
} | |||
end | end | ||
Line 340: | Line 377: | ||
paddingtop = '14px', | paddingtop = '14px', | ||
paddingtop2 = '14px' | paddingtop2 = '14px' | ||
} | |||
end | |||
--Bulk Haunting | |||
function p.bulkHaunting(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
return p.commonMachine{ | |||
args, | |||
manyInputs=false, | |||
manyOutputs=true, | |||
allowChance=true, | |||
slot='Bulk Haunting', | |||
paddingtop = '14px' | |||
} | } | ||
end | end | ||
Line 353: | Line 407: | ||
args, | args, | ||
manyInputs=false, | manyInputs=false, | ||
manyOutputs= | manyOutputs=false, | ||
allowChance=false, | allowChance=false, | ||
slot='Bulk Smoking', | slot='Bulk Smoking', | ||
Line 370: | Line 424: | ||
args, | args, | ||
manyInputs=false, | manyInputs=false, | ||
manyOutputs= | manyOutputs=false, | ||
allowChance=false, | allowChance=false, | ||
slot='Bulk Blasting', | slot='Bulk Blasting', | ||
paddingtop = '14px' | |||
} | |||
end | |||
--Deploying | |||
function p.deploying(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
return p.commonMachine{ | |||
args, | |||
manyInputs=true, | |||
manyOutputs=false, | |||
allowChance=false, | |||
slot='Deploying', | |||
paddingtop = '14px' | |||
} | |||
end | |||
--Manual Item Application | |||
function p.manualApplication(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
return p.commonMachine{ | |||
args, | |||
manyInputs=true, | |||
manyOutputs=false, | |||
allowChance=false, | |||
slot='Manual Item Application', | |||
paddingtop = '14px' | paddingtop = '14px' | ||
} | } | ||
Line 430: | Line 518: | ||
return p.commonMachine{ | return p.commonMachine{ | ||
args, | args, | ||
inputType = 'grid', | |||
manyOutputs=false, | manyOutputs=false, | ||
allowChance=false, | allowChance=false, | ||
isOneItemType=true, | |||
slot='Mechanical Press Crafting', | slot='Mechanical Press Crafting', | ||
paddingtop = '10px', | paddingtop = '10px', | ||
Line 478: | Line 567: | ||
} | } | ||
end | end | ||
-- | -- Mechanical Crafter | ||
function p.mechanicalCrafter(f) | function p.mechanicalCrafter(f) | ||
local args = f | local args = f | ||
Line 488: | Line 577: | ||
return p.commonMachine{ | return p.commonMachine{ | ||
args, | args, | ||
inputType = 'mechanicalCrafter', | |||
manyInputs=false, | manyInputs=false, | ||
manyOutputs=false, | manyOutputs=false, | ||
Line 511: | Line 599: | ||
manyOutputs=true, | manyOutputs=true, | ||
allowChance=false, | allowChance=false, | ||
slot=' | slot='Sawing', | ||
paddingtop = '14px' | |||
} | |||
end | |||
--Spout | |||
function p.spout(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
return p.commonMachine{ | |||
args, | |||
manyInputs=true, | |||
manyOutputs=false, | |||
allowChance=false, | |||
slot='Filling by Spout', | |||
paddingtop = '14px' | |||
} | |||
end | |||
--Sandpaper | |||
function p.sandpaper(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
return p.commonMachine{ | |||
args, | |||
manyInputs=false, | |||
manyOutputs=false, | |||
allowChance=false, | |||
slot='Sandpaper Polishing;Sandpaper Polishing (Red)', | |||
paddingtop = '14px' | paddingtop = '14px' | ||
} | } | ||
end | |||
-- Sequenced Assembly (WIP) | |||
function p.sequencedAssembly(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
local body = mw.html.create('span'):addClass('mcui mcui-Sequenced_Assembly pixel-image') | |||
local input = body:tag('span'):addClass('mcui-input') | |||
input:wikitext(addSlot(args, 'Input', 'I')) | |||
local Sequence = '' | |||
local Sequence1 = input:tag('span'):addClass('mcui-sequence1'):done() | |||
local Sequence2 = input:tag('span'):addClass('mcui-sequence2'):done() | |||
local Sequence3 input:tag('span'):addClass('mcui-sequence3'):done() | |||
end | end | ||
-- Common Machines | -- Common Machines | ||
Line 523: | Line 661: | ||
local i = 1 | local i = 1 | ||
local totalItems = 0 | local totalItems = 0 | ||
local | local inputRows = 0 | ||
local | local outputRows = 0 | ||
if options.inputType == 'grid' or options.inputType == 'mechanicalCrafter' then | if options.inputType == 'grid' or options.inputType == 'mechanicalCrafter' then | ||
input = body:tag('table'):addClass('mcui-input') | input = body:tag('table'):addClass('mcui-input') | ||
if options.inputType == 'mechanicalCrafter' then | if options.inputType == 'mechanicalCrafter' then | ||
Line 538: | Line 675: | ||
end | end | ||
if rowHasEntry then | if rowHasEntry then | ||
inputRows = inputRows + 1 | |||
local row = input:tag('tr'):addClass('mcui-row') | local row = input:tag('tr'):addClass('mcui-row') | ||
for letternum, letter in ipairs{ 'A', 'B', 'C', 'D', 'E' } do | for letternum, letter in ipairs{ 'A', 'B', 'C', 'D', 'E' } do | ||
Line 544: | Line 681: | ||
local td = row:tag('td') | local td = row:tag('td') | ||
if args[letter..num] and mw.text.trim(args[letter..num]) ~= '' then | if args[letter..num] and mw.text.trim(args[letter..num]) ~= '' then | ||
td:wikitext( | td:wikitext(slot{args[letter..num]}) | ||
totalItems = totalItems + 1 | totalItems = totalItems + 1 | ||
isEmptyRow = false | isEmptyRow = false | ||
Line 565: | Line 702: | ||
[5] = '6px', | [5] = '6px', | ||
} | } | ||
options.paddingtop = paddingtops[ | options.paddingtop = paddingtops[inputRows] | ||
elseif args.smallgrid then | elseif args.smallgrid then | ||
for num = 1, 2 do | for num = 1, 2 do | ||
local row = input:tag('tr'):addClass('mcui-row') | local row = input:tag('tr'):addClass('mcui-row') | ||
inputRows = inputRows + 1 | |||
for _, letter in ipairs{ 'A', 'B' } do | for _, letter in ipairs{ 'A', 'B' } do | ||
local td = row:tag('td') | local td = row:tag('td') | ||
td:wikitext( | local itemArg = options.isOneItemType and 'Input' or letter..num | ||
td:wikitext(slot{args[itemArg]}) | |||
end | end | ||
end | end | ||
Line 579: | Line 717: | ||
for num = 1, 3 do | for num = 1, 3 do | ||
local row = input:tag('tr'):addClass('mcui-row') | local row = input:tag('tr'):addClass('mcui-row') | ||
inputRows = inputRows + 1 | |||
for _, letter in ipairs{ 'A', 'B', 'C' } do | for _, letter in ipairs{ 'A', 'B', 'C' } do | ||
local td = row:tag('td') | local td = row:tag('td') | ||
td:wikitext( | local itemArg = options.isOneItemType and 'Input' or letter..num | ||
td:wikitext(slot{args[itemArg]}) | |||
end | end | ||
end | end | ||
Line 587: | Line 727: | ||
elseif options.inputType == 'normal' or not options.inputType then | elseif options.inputType == 'normal' or not options.inputType then | ||
input = body | input = body | ||
:tag(' | :tag('table') | ||
:addClass('mcui-input') | :addClass('mcui-input') | ||
:tag('tr') | |||
:addClass('mcui-row') | |||
while args['Input'..i] or args['I'..i] or (i == 1 and (args['Input'] or args['I'])) do | while args['Input'..i] or args['I'..i] or (i == 1 and (args['Input'] or args['I'])) do | ||
Line 599: | Line 741: | ||
local middle = body | local middle = body | ||
:tag('div') | :tag('div') | ||
:addClass( | :addClass('mcui-middle') | ||
middle:tag('div') | middle:tag('div') | ||
:wikitext(slot{ | :wikitext(slot{ | ||
options.slot | table.concat{ | ||
options.slot, ',', totalItems, | |||
(totalItems > 0 and table.concat{'[&7Requires ', totalItems, ' Crafters!]'} or ''), | |||
}, | |||
class = 'invslot-noformat' | class = 'invslot-noformat' | ||
}) | }) | ||
Line 650: | Line 782: | ||
end | end | ||
end | end | ||
if isChance then | |||
output:css{['top']='9px'} | |||
body:css{['padding-bottom']='9px'} | |||
end | |||
i = 1 | i = 1 | ||
local | local rows = {} | ||
local j = 1 | |||
while args['Output'..i] or args['O'..i] or (i == 1 and (args['Output'] or args['O'])) do | |||
if i % 5 == 1 then | |||
rows[j] = output:tag('tr'):addClass('mcui-row') | |||
outputRows = outputRows + 1 | |||
end | end | ||
local iItem = options.manyOutputs and (args['Output'..i] or args['O'..i]) or nil | |||
local item = i == 1 and (args['Output'] or args['O'] or iItem) or iItem | |||
local chance = i == 1 and (args['Chance'] or args['C'] or args['Chance'..i] or args['C'..i]) or (args['Chance'..i] or args['C'..i]) | |||
rows[j] = addSlotElement(rows[j], item, chance, isChance and options.allowChance, options.largeOutputSlot) | |||
i = i + 1 | |||
if i % 5 == 1 then j = j + 1 end | |||
end | end | ||
if isChance then | if isChance then | ||
Line 683: | Line 820: | ||
body:css{['padding-top'] = options.paddingtop or '14px'} | body:css{['padding-top'] = options.paddingtop or '14px'} | ||
end | end | ||
end | |||
if options.lowerslot then | |||
middle:css{['bottom']='0'} | |||
else | |||
local bottoms = { | |||
[0] = '11px', | |||
[1] = '12px', | |||
[2] = '5px', | |||
[3] = '-14px', | |||
[4] = '-31px', | |||
[5] = '-48px', | |||
} | |||
middle:css{['bottom']=bottoms[inputRows > outputRows and inputRows or outputRows] or options.bottom} | |||
end | end | ||
Line 709: | Line 860: | ||
end | end | ||
return element | return element | ||
end | |||
function p.slotList(f) | |||
local args = f | |||
if f == mw.getCurrentFrame() then | |||
args = f:getParent().args | |||
else | |||
f = mw.getCurrentFrame() | |||
end | |||
local maxWidth = tonumber(args.maxwidth or args.width or args.w) or 6 | |||
local wikitable = mw.html.create('table') | |||
:addClass('mcui-output') | |||
local i = 1 | |||
while args[i] and mw.text.trim(args[i]) ~= '' do | |||
local row = wikitable:tag('tr'):addClass('mcui-row') | |||
local j = 1 | |||
while args[i] and mw.text.trim(args[i]) ~= '' and j <= maxWidth do | |||
row:tag('td'):wikitext(slot{args[i], class='invslot-noformat'}):done() | |||
i = i + 1 | |||
j = j + 1 | |||
end | |||
end | |||
return tostring(wikitable) | |||
end | end | ||
return p | return p |
Latest revision as of 21:59, 14 February 2025
Documentation for this module may be created at Module:UI/doc
local slot = require( [[Module:Inventory slot]] ).slot
local function addSlot(args, item, prefix, class, default)
local none, nostacksize
prefix = prefix or ''
if #prefix == 0 then
none = 'none'
nostacksize = ((item == '' or nil) and '') or (args and args[item] and args[item]:gsub('[,%d]', '') or '')
end
return slot{
nostacksize or args[item], mod = args.Mod, link = none or args[prefix .. 'link'],
title = none or args[prefix .. 'title'], class = class, default = default,
parsed = args.parsed, forcenum = args.forcenum
}
end
local p = {}
-- Crafting table
function p.craftingTable(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Crafting_Table pixel-image')
-- CUSTOM: changing grid to use <table> since wikia mobile doesn't support CSS
local input = body:tag('table'):addClass('mcui-input')
for num = 1, 3 do
local row = input:tag('tr'):addClass('mcui-row')
for _, letter in ipairs{ 'A', 'B', 'C' } do
local td = row:tag('td')
td:wikitext(addSlot(args, letter .. num, 'I'))
end
end
local arrow = body:tag('span'):addClass('mcui-arrow'):tag('br'):done()
if args.arrow or '' ~= '' then
arrow:css(
'background-image',
'{{FileUrl|' .. args.arrow .. ' (' .. args.Mod .. ').png}}'
)
end
body
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O', 'invslot-large'))
local shapeless = args.shapeless or ''
local fixed = args.fixed or ''
if shapeless ~= '' or fixed ~= '' then
local icon = body:tag('span')
:addClass('mcui-icons')
:tag('span')
:tag('br')
:done()
if shapeless ~= '' then
icon:addClass('mcui-shapeless')
:attr('title',
'This recipe is shapeless, the inputs may be placed in any arrangement in the crafting grid.'
)
elseif fixed ~= '' then
local notFixed = args.notfixed or ''
local exceptFixed = ''
if notFixed ~= '' then
exceptFixed = '; except for ' .. notFixed .. ', which can go anywhere'
end
icon:addClass('mcui-fixed')
:attr('title',
'This recipe is fixed, the input arrangement may not be moved or mirrored in the crafting grid' .. exceptFixed .. '.'
)
end
end
return tostring(mw.html.create('div'):node(body))
end
-- Furnace
function p.furnace(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Furnace pixel-image')
local input = body:tag('span'):addClass('mcui-input')
input:wikitext(addSlot(args, 'Input', 'I'))
local fuel = input:tag('span'):addClass('mcui-fuel'):tag('br'):done()
local fuelImg = args.FuelUsage or ''
local burning = args.Input or '' ~= '' and args.Fuel or '' ~= ''
if not burning then
fuel:addClass('mcui-inactive')
if fuelImg ~= '' then
fuelImg = fuelImg .. ' (in-active)'
end
end
if fuelImg ~= '' then
fuel:css(
'background-image',
'{{FileUrl|' .. fuelImg .. ' (' .. args.Mod .. ').png}}'
)
end
input:wikitext(addSlot(args, 'Fuel', 'F'))
local arrow = body:tag('span'):addClass('mcui-arrow'):tag('br'):done()
local arrowImg = args.Progress or ''
if not burning or (args.Output or '') == '' then
arrow:addClass('mcui-inactive')
if arrowImg ~= '' then
arrowImg = arrowImg .. ' (in-active)'
end
end
if arrowImg ~= '' then
arrow:css(
'background-image',
'{{FileUrl|' .. arrowImg .. ' Progress (' .. args.Mod .. ').png}}'
)
end
body
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O', 'invslot-large'))
return tostring(mw.html.create('div'):node(body))
end
-- Brewing Stand
function p.brewingStand(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Brewing_Stand pixel-image')
local input = body:tag('span'):addClass('mcui-input')
input:tag('span'):addClass('mcui-bubbling'):tag('br')
input:wikitext(addSlot(args, 'Input', 'I'))
input:tag('span'):addClass('mcui-arrow'):tag('br')
if (args.Input or '') == '' or
((args.Output1 or '') == '' and (args.Output2 or '') == '' and (args.Output3 or '') == '')
then
input:addClass('mcui-inactive')
end
body:tag('span'):addClass('mcui-paths'):tag('br')
local output = body:tag('span'):addClass('mcui-output')
for i = 1, 3 do
output:wikitext(addSlot(args, 'Output' .. i, 'O' .. i, 'mcui-output' .. i))
end
return tostring(mw.html.create('div'):node(body))
end
-- Stonecutter
function p.stonecutter(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Stonecutter pixel-image')
local input = body:tag('span'):addClass('mcui-input')
input:wikitext(addSlot(args, 'Input', 'I'))
local arrow = body:tag('span'):addClass('mcui-stonecutterArrow')
if (args.arrow or '') ~= '' then
arrow:css(
'background-image',
'{{FileUrl|' .. args.arrow .. ' (' .. args.Mod .. ').png}}'
)
end
arrow:wikitext(addSlot(args, 'Output', '', 'invslot-plain invslot-noformat mcui-stonecutterSprite'))
body
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O', 'invslot-large'))
return tostring(mw.html.create('div'):node(body))
end
-- Pre-1.20 Smithing Table
function p.legacySmithing(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-legacySmithing pixel-image')
body:tag('span'):addClass('mcui-text'):wikitext('Upgrade Gear'):done()
body:tag('span'):addClass('mcui-smithingHammer'):tag('br'):done()
local bottom = body:tag('div'):addClass('mcui-bottom')
local input = bottom:tag('span'):addClass('mcui-input')
input:wikitext(addSlot(args, 'Input1', 'I1'))
input:tag('span'):addClass('mcui-plus'):done()
input:wikitext(addSlot(args, 'Input2', 'I2'))
bottom:tag('span'):addClass('mcui-arrow'):tag('br'):done()
bottom
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O'))
return tostring(mw.html.create('div'):node(body))
end
-- Post-1.20 Smithing Table
function p.smithingTable(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-smithingTable pixel-image')
body:tag('span'):addClass('mcui-text'):wikitext('Upgrade Gear'):done()
body:tag('span'):addClass('mcui-smithingHammer'):tag('br'):done()
local bottom = body:tag('div'):addClass('mcui-bottom')
local input = bottom:tag('span'):addClass('mcui-input')
input:wikitext(addSlot(args, 'Input1', 'I1'))
input:wikitext(addSlot(args, 'Input2', 'I2'))
input:wikitext(addSlot(args, 'Input3', 'I3'))
bottom:tag('span'):addClass('mcui-arrow'):tag('br'):done()
bottom
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O'))
return tostring(mw.html.create('div'):node(body))
end
-- Loom
function p.loom(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Loom pixel-image')
local tapestry = body:tag('span'):addClass('mcui-tapestry')
if args.Banner and #args.Banner>0 then
tapestry:wikitext(addSlot(args, 'Banner', 'B', 'mcui-inputBanner'))
end
if args.Dye and #args.Dye>0 then
tapestry:wikitext(addSlot(args, 'Dye', 'D', 'mcui-inputDye'))
end
if args.Pattern and #args.Pattern>0 then
tapestry:wikitext(addSlot(args, 'Pattern', 'P', 'mcui-inputPattern'))
end
tapestry:tag('span'):tag('br'):done()
local arrow = body:tag('span'):addClass('mcui-loomArrow')
if args.arrow or '' ~= '' then
arrow:css(
'background-image',
'{{FileUrl|' .. args.arrow .. ' (' .. args.Mod .. ').png}}'
)
end
local sprite = args.Sprite
local bannerSprite
if sprite and #sprite>0 then
local animate = require([[Module:AnimateSprite]]).animate
bannerSprite = animate{
args.Sprite,
sheet = 'SlotSprite'
}
else
bannerSprite = '<br>'
end
arrow
:tag('span')
:addClass('mcui-bannerSprite')
:wikitext(bannerSprite)
body
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O', 'invslot-large'))
return tostring(mw.html.create('div'):node(body))
end
-- Grindstone
function p.grindstone(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Grindstone pixel-image')
local grindstone = body:tag('span'):addClass('mcui-grindstone')
grindstone:wikitext(addSlot(args, 'Input1', 'I1', 'mcui-input1'))
grindstone:wikitext(addSlot(args, 'Input2', 'I2', 'mcui-input2'))
local arrow = body:tag('span'):addClass('mcui-arrow')
if args.arrow or '' ~= '' then
arrow:css(
'background-image',
'{{FileUrl|' .. args.arrow .. ' (' .. args.Mod .. ').png}}'
)
end
body
:tag('span')
:addClass('mcui-output')
:wikitext(addSlot(args, 'Output', 'O', 'invslot-large'))
return tostring(mw.html.create('div'):node(body))
end
-- Crushing Wheel
function p.crushingWheel(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=true,
allowChance=true,
slot='Crushing',
paddingtop = '14px',
paddingtop2 = '14px'
}
end
--Bulk Washing
function p.bulkWashing(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=true,
allowChance=true,
slot='Bulk Washing',
paddingtop = '14px',
paddingtop2 = '14px'
}
end
--Bulk Haunting
function p.bulkHaunting(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=true,
allowChance=true,
slot='Bulk Haunting',
paddingtop = '14px'
}
end
--Bulk Smoking
function p.bulkSmoking(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=false,
allowChance=false,
slot='Bulk Smoking',
paddingtop = '14px'
}
end
--Bulk Blasting
function p.bulkBlasting(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=false,
allowChance=false,
slot='Bulk Blasting',
paddingtop = '14px'
}
end
--Deploying
function p.deploying(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Deploying',
paddingtop = '14px'
}
end
--Manual Item Application
function p.manualApplication(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Manual Item Application',
paddingtop = '14px'
}
end
--Mechanical Mixer
function p.mechanicalMixer(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
if args.type:lower() == 'crafting' or args.type:lower() == 'shapeless' then
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Mechanical Mixer Crafting',
paddingtop = '14px'
}
elseif args.type:lower() == 'mixing' then
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Mechanical Mixer Mixing',
lowerslot=args.Heating,
paddingtop = args.Heating and '6px' or '14px',
paddingbottom = '0'
}
elseif args.type:lower() == 'brewing' then
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Mechanical Mixer Brewing',
lowerslot=args.Heating,
paddingtop = args.Heating and '6px' or '14px',
paddingbottom = '0'
}
else
return '<strong><font color="red">Template error: invalid type specified</font></strong>'
end
end
--Mechanical Press
function p.mechanicalPress(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
if args.type:lower() == 'crafting' or args.type:lower() == 'packing' then
return p.commonMachine{
args,
inputType = 'grid',
manyOutputs=false,
allowChance=false,
isOneItemType=true,
slot='Mechanical Press Crafting',
paddingtop = '10px',
paddingbottom = '6px',
paddingtop2 = '6px',
}
elseif args.type:lower() == 'compacting' then
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Mechanical Press Compacting',
paddingtop = '14px',
}
elseif args.type:lower() == 'pressing' then
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=false,
allowChance=false,
slot='Mechanical Press Pressing',
paddingtop = '14px',
}
else
return '<strong><font color="red">Template error: invalid type specified</font></strong>'
end
end
-- Millstone
function p.millstone(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=true,
allowChance=true,
slot='Milling',
paddingtop = '14px',
paddingtop2 = '20px'
}
end
-- Mechanical Crafter
function p.mechanicalCrafter(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
inputType = 'mechanicalCrafter',
manyInputs=false,
manyOutputs=false,
allowChance=false,
slot='Mechanical Crafting',
paddingbottom = '6px',
largeOutputSlot = true,
}
end
--Mechanical Saw
function p.mechanicalSaw(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=true,
allowChance=false,
slot='Sawing',
paddingtop = '14px'
}
end
--Spout
function p.spout(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=true,
manyOutputs=false,
allowChance=false,
slot='Filling by Spout',
paddingtop = '14px'
}
end
--Sandpaper
function p.sandpaper(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
return p.commonMachine{
args,
manyInputs=false,
manyOutputs=false,
allowChance=false,
slot='Sandpaper Polishing;Sandpaper Polishing (Red)',
paddingtop = '14px'
}
end
-- Sequenced Assembly (WIP)
function p.sequencedAssembly(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local body = mw.html.create('span'):addClass('mcui mcui-Sequenced_Assembly pixel-image')
local input = body:tag('span'):addClass('mcui-input')
input:wikitext(addSlot(args, 'Input', 'I'))
local Sequence = ''
local Sequence1 = input:tag('span'):addClass('mcui-sequence1'):done()
local Sequence2 = input:tag('span'):addClass('mcui-sequence2'):done()
local Sequence3 input:tag('span'):addClass('mcui-sequence3'):done()
end
-- Common Machines
function p.commonMachine(options)
local args = options[1]
local body = mw.html.create('span'):addClass('mcui mcui-Common_Machines pixel-image')
local input
local i = 1
local totalItems = 0
local inputRows = 0
local outputRows = 0
if options.inputType == 'grid' or options.inputType == 'mechanicalCrafter' then
input = body:tag('table'):addClass('mcui-input')
if options.inputType == 'mechanicalCrafter' then
for num = 1, 5 do
local rowHasEntry = false
for _, letter in ipairs{ 'A', 'B', 'C', 'D', 'E' } do
if args[letter..num] and mw.text.trim(args[letter..num]) ~= '' then
rowHasEntry = true
break
end
end
if rowHasEntry then
inputRows = inputRows + 1
local row = input:tag('tr'):addClass('mcui-row')
for letternum, letter in ipairs{ 'A', 'B', 'C', 'D', 'E' } do
if not args.gridwidth or letternum <= tonumber(args.gridwidth) then
local td = row:tag('td')
if args[letter..num] and mw.text.trim(args[letter..num]) ~= '' then
td:wikitext(slot{args[letter..num]})
totalItems = totalItems + 1
isEmptyRow = false
else
td:wikitext(slot{
nil,
class='invslot-noformat'
})
end
end
end
end
end
local paddingtops = {
[0] = '0',
[1] = '18px',
[2] = '8px',
[3] = '6px',
[4] = '6px',
[5] = '6px',
}
options.paddingtop = paddingtops[inputRows]
elseif args.smallgrid then
for num = 1, 2 do
local row = input:tag('tr'):addClass('mcui-row')
inputRows = inputRows + 1
for _, letter in ipairs{ 'A', 'B' } do
local td = row:tag('td')
local itemArg = options.isOneItemType and 'Input' or letter..num
td:wikitext(slot{args[itemArg]})
end
end
else
for num = 1, 3 do
local row = input:tag('tr'):addClass('mcui-row')
inputRows = inputRows + 1
for _, letter in ipairs{ 'A', 'B', 'C' } do
local td = row:tag('td')
local itemArg = options.isOneItemType and 'Input' or letter..num
td:wikitext(slot{args[itemArg]})
end
end
end
elseif options.inputType == 'normal' or not options.inputType then
input = body
:tag('table')
:addClass('mcui-input')
:tag('tr')
:addClass('mcui-row')
while args['Input'..i] or args['I'..i] or (i == 1 and (args['Input'] or args['I'])) do
local iItem = options.manyInputs and (args['Input'..i] or args['I'..i]) or nil
local item = i == 1 and (args['Input'] or args['I'] or iItem) or iItem
input = addSlotElement(input, item)
i = i + 1
end
end
local middle = body
:tag('div')
:addClass('mcui-middle')
middle:tag('div')
:wikitext(slot{
table.concat{
options.slot, ',', totalItems,
(totalItems > 0 and table.concat{'[&7Requires ', totalItems, ' Crafters!]'} or ''),
},
class = 'invslot-noformat'
})
:done()
middle
:tag('div')
:addClass(options.arrowclass or 'mcui-arrow-long')
:done()
if options.lowerslot then
middle:tag('div')
:css{
['position']='relative',
['bottom']='8px',
}
:wikitext(slot{
options.lowerslot,
class = 'invslot-noformat'
})
:done()
end
local output = body
:tag('table')
:addClass('mcui-output')
local isChance = false
if options.allowChance == nil then options.allowChance = true end
if options.allowChance then
for j=1,50,1 do
if args['Chance'..j] or args['C'..j] then
isChance = true
break
end
end
end
if isChance then
output:css{['top']='9px'}
body:css{['padding-bottom']='9px'}
end
i = 1
local rows = {}
local j = 1
while args['Output'..i] or args['O'..i] or (i == 1 and (args['Output'] or args['O'])) do
if i % 5 == 1 then
rows[j] = output:tag('tr'):addClass('mcui-row')
outputRows = outputRows + 1
end
local iItem = options.manyOutputs and (args['Output'..i] or args['O'..i]) or nil
local item = i == 1 and (args['Output'] or args['O'] or iItem) or iItem
local chance = i == 1 and (args['Chance'] or args['C'] or args['Chance'..i] or args['C'..i]) or (args['Chance'..i] or args['C'..i])
rows[j] = addSlotElement(rows[j], item, chance, isChance and options.allowChance, options.largeOutputSlot)
i = i + 1
if i % 5 == 1 then j = j + 1 end
end
if isChance then
if options.paddingbottom then
body:css{
['padding-top'] = options.paddingtop2 or '20px',
['padding-bottom'] = options.paddingbottom or '0'
}
else
body:css{['padding-top'] = options.paddingtop2 or '20px'}
end
else
if options.paddingbottom then
body:css{
['padding-top'] = options.paddingtop or '14px',
['padding-bottom'] = options.paddingbottom or '0'
}
else
body:css{['padding-top'] = options.paddingtop or '14px'}
end
end
if options.lowerslot then
middle:css{['bottom']='0'}
else
local bottoms = {
[0] = '11px',
[1] = '12px',
[2] = '5px',
[3] = '-14px',
[4] = '-31px',
[5] = '-48px',
}
middle:css{['bottom']=bottoms[inputRows > outputRows and inputRows or outputRows] or options.bottom}
end
return tostring(mw.html.create('div'):node(body))
end
function addSlotElement(element, item, chance, allowChance, largeOutputSlot)
if allowChance then
element
:css{['top']='9px'}
:tag('td')
:tag('span')
:wikitext(slot{item})
:done()
:tag('span')
:addClass(chance and 'mcui-text' or 'mcui-text mcui-text-nondisplay')
:wikitext(chance or 'nil')
:done()
:done()
:done()
else
element
:tag('td')
:wikitext(slot{item, class=largeOutputSlot and 'invslot-large' or nil})
:done()
:done()
end
return element
end
function p.slotList(f)
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
else
f = mw.getCurrentFrame()
end
local maxWidth = tonumber(args.maxwidth or args.width or args.w) or 6
local wikitable = mw.html.create('table')
:addClass('mcui-output')
local i = 1
while args[i] and mw.text.trim(args[i]) ~= '' do
local row = wikitable:tag('tr'):addClass('mcui-row')
local j = 1
while args[i] and mw.text.trim(args[i]) ~= '' and j <= maxWidth do
row:tag('td'):wikitext(slot{args[i], class='invslot-noformat'}):done()
i = i + 1
j = j + 1
end
end
return tostring(wikitable)
end
return p