Module:Crafting: Difference between revisions
From Vintage Story Wiki
(Created page with "local p = {} function p.main(f) local args = require( 'Module:ProcessArgs' ).merge( true ) local cells = {} cells[1] = args.A1 or '' cells[2] = args.B1 or '' cells[3]...") |
mNo edit summary |
||
Line 27: | Line 27: | ||
local inputItems = {} | local inputItems = {} | ||
for cell in cells do | for cell in pairs(cells) do | ||
if cell ~= '' then | if cell ~= '' then | ||
table.insert(inputItems, cell) | table.insert(inputItems, cell) |
Revision as of 21:26, 22 August 2022
Documentation for this module may be created at Module:Crafting/doc
local p = {}
function p.main(f)
local args = require( 'Module:ProcessArgs' ).merge( true )
local cells = {}
cells[1] = args.A1 or ''
cells[2] = args.B1 or ''
cells[3] = args.C1 or ''
cells[4] = args.A2 or ''
cells[5] = args.B2 or ''
cells[6] = args.C2 or ''
cells[7] = args.A3 or ''
cells[8] = args.B3 or ''
cells[9] = args.C3 or ''
local cellsAlt = {}
cellsAlt[1] = args.A1_alt or ''
cellsAlt[2] = args.B1_alt or ''
cellsAlt[3] = args.C1_alt or ''
cellsAlt[4] = args.A2_alt or ''
cellsAlt[5] = args.B2_alt or ''
cellsAlt[6] = args.C2_alt or ''
cellsAlt[7] = args.A3_alt or ''
cellsAlt[8] = args.B3_alt or ''
cellsAlt[9] = args.C3_alt or ''
local inputItems = {}
for cell in pairs(cells) do
if cell ~= '' then
table.insert(inputItems, cell)
end
end
local ingredients
ingredients = table.concat(ingredients, ' + \n')
local background = '<td><div style="position:relative; width:170px; height:240px; background: rgb(91,76,62); background: linear-gradient(to bottom, rgba(91,76,62,1) 0px, rgba(91,76,62,0) 15px, rgba(56,43,30,0) calc(100% - 15px), rgba(56,43,30,1) 100%), linear-gradient(to left, rgba(91,76,62,1) 0px, rgba(69,52,36,1) 15px, #403529 50%, rgba(69,52,36,1) calc(100% - 15px), rgba(56,43,30,1) 100%);">'
local notes
if args.notes then
notes = '<th style="width:400px"><b>Notes</b></th>'
else
notes = ''
end
local header
if args.header then
header = '<table class="wikitable mw-collapsible"> <tr><th style="width:200px"><b>Ingredients</b></th> <th><b>Crafting recipe</b></th>' .. notes .. '</tr>'
end
local hCells = {}
i = 1
repeat
table.insert(hCells, '{{Item cell|' .. i .. '|{{{' .. cells[i] .. '|}}}|{{{' .. cellsAlt[i] .. '|}}} }}')
i = i + 1
until i == 11
local body = header .. '<tr style="text-align:center;"><td>' .. ingredients .. '</td>' .. backgroud .. hCells .. '</td>'
if notes ~= '' then
body = body .. '<td style="text-align:left;">' .. notes .. '</td>'
end
body = body .. '</tr>'
if args.footer then
body = body .. '</table>'
end
return body
end
return p