Module:CraftingRecipe: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
local productList = mw.text.split(products, ',') | local productList = mw.text.split(products, ',') | ||
local result = '{| class="wikitable" | local result = '{| class="wikitable"\n' | ||
-- Ingredients Header | |||
result = result .. '! colspan="2" style="text-align:center;" | Ingredients\n' | |||
result = result .. '|-\n! Item !! Amount\n' | |||
-- Ingredients Rows | |||
for _, item in ipairs(ingredientList) do | for _, item in ipairs(ingredientList) do | ||
local parts = mw.text.split(item, ':') | local parts = mw.text.split(item, ':') | ||
result = result .. '|-\n | result = result .. '|-\n| ' .. parts[1] .. ' || ' .. parts[2] .. '\n' | ||
end | end | ||
-- Products Header | |||
result = result .. '|-\n! colspan="2" style="text-align:center;" | Products\n' | |||
result = result .. '|-\n! Item !! Amount\n' | |||
-- Products Rows | |||
for _, product in ipairs(productList) do | for _, product in ipairs(productList) do | ||
local parts = mw.text.split(product, ':') | local parts = mw.text.split(product, ':') | ||
result = result .. '|-\n | result = result .. '|-\n| ' .. parts[1] .. ' || ' .. parts[2] .. '\n' | ||
end | end | ||
Latest revision as of 10:36, 24 June 2025
Documentation for this module may be created at Module:CraftingRecipe/doc
local p = {}
function p.show(frame)
local ingredients = frame.args['ingredients']
local products = frame.args['products']
local ingredientList = mw.text.split(ingredients, ',')
local productList = mw.text.split(products, ',')
local result = '{| class="wikitable"\n'
-- Ingredients Header
result = result .. '! colspan="2" style="text-align:center;" | Ingredients\n'
result = result .. '|-\n! Item !! Amount\n'
-- Ingredients Rows
for _, item in ipairs(ingredientList) do
local parts = mw.text.split(item, ':')
result = result .. '|-\n| ' .. parts[1] .. ' || ' .. parts[2] .. '\n'
end
-- Products Header
result = result .. '|-\n! colspan="2" style="text-align:center;" | Products\n'
result = result .. '|-\n! Item !! Amount\n'
-- Products Rows
for _, product in ipairs(productList) do
local parts = mw.text.split(product, ':')
result = result .. '|-\n| ' .. parts[1] .. ' || ' .. parts[2] .. '\n'
end
result = result .. '|}'
return result
end
return p