Editing Module:RecipeTable
From Eco - English Wiki
Your changes will be displayed to readers once an authorized user accepts them. (help)
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 34: | Line 34: | ||
elseif style == 'skill' then | elseif style == 'skill' then | ||
iconBG = 'iconBrightBlue' | iconBG = 'iconBrightBlue' | ||
name = nameEN | |||
end | end | ||
Line 41: | Line 41: | ||
end | end | ||
return Utils.build_icon(icon | return Utils.build_icon(icon, 'iconRecipe', iconBG, borderImageClass, true) .. '\n[[' .. name .. ']]' | ||
end | end | ||
Line 94: | Line 94: | ||
function p.main(recipes) | function p.main(recipes) | ||
local rows = '' | local rows = '' | ||
-- Get each row | -- Get each row | ||
for i = 1, #recipes do | for i = 1, #recipes do | ||
Line 102: | Line 103: | ||
--use last variant as this is always the default variant | --use last variant as this is always the default variant | ||
local numberOfVariants = recipes[i].numberOfVariants | local numberOfVariants = recipes[i].numberOfVariants | ||
local products = {} | local products = { { '', '', '' } } | ||
local ingredients = {} | local ingredients = { { '', '' } } | ||
--loop through variants to select default variant ingredients | --loop through variants to select default variant ingredients | ||
for k, v in pairs(recipes[i].variants) do | |||
--given pairs doesn't guarantee order, check that product matches default variant | |||
if k == recipes[i].defaultVariant then | |||
ingredients = v.ingredients | |||
products = v.products | |||
end | end | ||
end | end | ||
Line 158: | Line 153: | ||
-- Add new row if products or ingredients are passed in with at least 1 item | -- Add new row if products or ingredients are passed in with at least 1 item | ||
if (products[1] and ingredients[1]) then | if (products[1] and ingredients[1]) then | ||
-- Show or hide the Crafting Station column | -- Show or hide the Crafting Station column | ||
if recipes[i].dispCraftStn == '1' then | if recipes[i].dispCraftStn == '1' then | ||
row = row .. rowspan .. stationcell({ | row = row .. rowspan .. stationcell({ craftStn[1][1], craftStn[1][2] }) .. '\n' | ||
end | end | ||
Line 258: | Line 251: | ||
rows = rows .. row | rows = rows .. row | ||
end | end | ||
Line 304: | Line 296: | ||
-- Return the full wikitable | -- Return the full wikitable | ||
return header({ recipes[1].dispCraftStn }) .. rows .. '|-\n|}\n' | return header({ recipes[1].dispCraftStn }) .. rows .. '|-\n|}\n' | ||
end | end | ||
return p | return p |