https://wiki.celestek.xyz/index.php?title=Module:Smelting&feed=atom&action=history
Module:Smelting - Revision history
2024-03-28T15:10:01Z
Revision history for this page on the wiki
MediaWiki 1.24.2
//wiki.celestek.xyz/index.php?title=Module:Smelting&diff=234&oldid=prev
Celestek at 10:54, 14 May 2015
2015-05-14T10:54:41Z
<p></p>
<p><b>New page</b></p><div>local p = {}<br />
function p.table( f )<br />
local args = f<br />
if f == mw.getCurrentFrame() then<br />
args = f:getParent().args<br />
else<br />
f = mw.getCurrentFrame()<br />
end<br />
local grid = require( 'Module:Grid' )<br />
<br />
-- Start table when appropriate<br />
local multirow = f:callParserFunction( '#dplvar', 'multirow' )<br />
if multirow ~= '1' then<br />
multirow = nil<br />
end<br />
local head = args.head or ''<br />
if multirow then<br />
head = ''<br />
elseif head ~= '' then<br />
multirow = 1<br />
f:callParserFunction( '#dplvar:set', 'multirow', '1' )<br />
else<br />
head = 1<br />
end<br />
<br />
-- End table when appropriate<br />
local foot = args.foot or ''<br />
if multirow then<br />
if foot ~= '' then<br />
multirow = nil<br />
f:callParserFunction( '#dplvar:set', 'multirow', '0' )<br />
end<br />
else<br />
foot = 1<br />
end<br />
<br />
local header = ''<br />
if head ~= '' then<br />
local name = ''<br />
local description = ''<br />
if args.showname == '1' or multirow and args.showname ~= '0' then<br />
name = 'Name !! '<br />
f:callParserFunction( '#dplvar:set', 'smeltingname', '1' )<br />
end<br />
if args.showdescription == '1' then<br />
description = ' !! class="unsortable" | Description'<br />
f:callParserFunction( '#dplvar:set', 'smeltingdescription', '1' )<br />
end<br />
local class = args.class or ''<br />
local recipeClass = ''<br />
if multirow then<br />
class = 'sortable collapsible ' .. class<br />
recipeClass = 'class="unsortable collapse-button" |'<br />
end<br />
header = table.concat( {<br />
' {| class="wikitable ' .. '"',<br />
'! ' .. name .. 'Ingredients !! ' .. ' [[Smelting]] recipe' .. description,<br />
'|-'<br />
}, '\n' )<br />
end<br />
<br />
local input = mw.text.trim( args[1] or '' )<br />
local output = mw.text.trim( args[2] or '' )<br />
local fuel = args.fuel or ''<br />
if fuel == '' then<br />
fuel = 'Any fuel'<br />
end<br />
<br />
-- Name cell<br />
local nameCell<br />
if args.name or '' ~= '' then<br />
nameCell = args.name<br />
elseif multirow or f:callParserFunction( '#dplvar', 'smeltingname' ) == '1' then<br />
local names = {}<br />
local links = {}<br />
for v in mw.text.gsplit( args[2] or '', '%s*;%s*' ) do<br />
parts = grid.getParts( v )<br />
if not names[( parts.mod or '' ) .. parts.name] then<br />
local link = ''<br />
if parts.mod then<br />
link = 'Mods/' .. parts.mod .. '/' .. parts.name .. '|'<br />
end<br />
<br />
if parts.name:find( '^Any ' ) then<br />
table.insert( links, 'Any [[' .. link .. parts.name:sub( 4 ) .. ']]' )<br />
else<br />
table.insert( links, '[[' .. link .. parts.name .. ']]' )<br />
end<br />
names[( parts.mod or '' ) .. parts.name] = 1<br />
end<br />
end<br />
<br />
nameCell = table.concat( links, '&nbsp;or<br>' )<br />
end<br />
<br />
if nameCell and args.upcoming then<br />
nameCell = nameCell .. '<br>([[' .. args.upcoming .. ']])'<br />
end<br />
<br />
-- Ingredients cell<br />
local ingredientsCell<br />
if args.ingredients or '' ~= '' then<br />
ingredientsCell = args.ingredients<br />
else<br />
ingredientsCell = {}<br />
local ingredients = {}<br />
for k, v in ipairs{ input, fuel } do<br />
local separator = ''<br />
if k == 2 and next( ingredients ) then<br />
separator = '&nbsp;+<br>\n'<br />
end<br />
for item in mw.text.gsplit( v, '%s*;%s*' ) do<br />
local parts = grid.getParts( item )<br />
if parts.name ~= '' and not ingredients[parts.name] and ( k == 2 or k == 1 and v ~= fuel ) then<br />
local link = ''<br />
if separator == '' and next( ingredients ) then<br />
separator = '&nbsp;or<br>\n'<br />
end<br />
<br />
if parts.mod then<br />
link = 'Mods/'.. parts.mod .. '/' .. parts.name .. '|'<br />
end<br />
<br />
if parts.name:find( '^Any ' ) then<br />
table.insert( ingredientsCell, separator .. 'Any [[' .. link .. parts.name:sub( 4 ) .. ']]' )<br />
else<br />
table.insert( ingredientsCell, separator .. '[[' .. link .. parts.name .. ']]' )<br />
end<br />
separator = ''<br />
<br />
ingredients[parts.name] = 1<br />
end<br />
end<br />
end<br />
<br />
ingredientsCell = table.concat( ingredientsCell )<br />
end<br />
<br />
-- Any args we want to pass along<br />
local newArgs = {<br />
Input = args[1],<br />
Output = args[2],<br />
Fuel = fuel,<br />
Ititle = args.Ititle,<br />
Otitle = args.Otitle,<br />
Ftitle = args.Ftitle<br />
}<br />
<br />
-- Recipe cell<br />
local recipeCell = grid.furnace( newArgs )<br />
<br />
local row = { ingredientsCell, recipeCell }<br />
if nameCell then<br />
table.insert( row, 1, nameCell )<br />
end<br />
if f:callParserFunction( '#dplvar', 'smeltingdescription' ) == '1' then<br />
table.insert( row, args.description or '' )<br />
end<br />
row = table.concat( row, '\n|\n' )<br />
<br />
if nameCell then<br />
row = '!\n' .. row<br />
else<br />
row = '|\n' .. row<br />
end<br />
<br />
local footer = ''<br />
if foot ~= '' then<br />
footer = '|}'<br />
f:callParserFunction( '#dplvar:set', 'smeltingname', '0', 'smeltingdescription', '0' )<br />
end<br />
<br />
local title = mw.title.getCurrentTitle()<br />
local category = ''<br />
if args.upcoming and args.nocat ~= '1' and title.namespace == 0 and not title.isSubpage then<br />
category = '[[Category:Upcoming]]'<br />
end<br />
<br />
return header .. '\n' .. row .. '\n|-\n' .. footer .. category<br />
end<br />
return p</div>
Celestek