Module:CraftingTable: Difference between revisions

From Ylvapedia
No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 3: Line 3:
local function isBlank(value)
local function isBlank(value)
return value == nil or not value or value == ''
return value == nil or not value or value == ''
end
local function TSafely(f, templateName, args)
local result = f:expandTemplate{ title=templateName, args=args }
if not result then
mw.log('Template '..templateName..' expansion failed')
return ''
end
return result
end
end


function p.crafttable(f)
function p.crafttable(f)
local args = f:getParent().args
local args = f:getParent().args
local lang = f.args[1]
local lang = f.args[1]
local data = mw.loadData('Module:CraftingTable/i18n')
local i18n = mw.loadData('Module:CraftingTable/i18n') or {}
local title = mw.title.getCurrentTitle()
local title = mw.title.getCurrentTitle()
local Recipe = {
local recipes = {
{
{
CraftingStation = args[data[lang]['CraftingStation']] or '',
craftingStation = args[i18n[lang]['CraftingStation']] or '',
Ingredient = args[data[lang]['Ingredient']] or '',
ingredient = args[i18n[lang]['Ingredient']] or '',
IngredientNum = args[data[lang]['IngredientNum']] or '',
ingredientNum = args[i18n[lang]['IngredientNum']] or '',
IngredientExtra = args[data[lang]['IngredientExtra']] or '',
ingredientExtra = args[i18n[lang]['IngredientExtra']] or '',
CraftResult = args[data[lang]['TitleResult']] or '',
craftResult = args[i18n[lang]['TitleResult']] or '',
},
},
{
{
CraftingStation = args[data[lang]['CraftingStation']..'2'] or '',
craftingStation = args[i18n[lang]['CraftingStation']..'2'] or '',
Ingredient = args[data[lang]['Ingredient']..'2'] or '',
ingredient = args[i18n[lang]['Ingredient']..'2'] or '',
IngredientNum = args[data[lang]['IngredientNum']..'2'] or '',
ingredientNum = args[i18n[lang]['IngredientNum']..'2'] or '',
IngredientExtra = args[data[lang]['IngredientExtra']..'2'] or '',
ingredientExtra = args[i18n[lang]['IngredientExtra']..'2'] or '',
CraftResult = args[data[lang]['TitleResult']..'2'] or '',
craftResult = args[i18n[lang]['TitleResult']..'2'] or '',
},
},
{
{
CraftingStation = args[data[lang]['CraftingStation']..'3'] or '',
craftingStation = args[i18n[lang]['CraftingStation']..'3'] or '',
Ingredient = args[data[lang]['Ingredient']..'3'] or '',
ingredient = args[i18n[lang]['Ingredient']..'3'] or '',
IngredientNum = args[data[lang]['IngredientNum']..'3'] or '',
ingredientNum = args[i18n[lang]['IngredientNum']..'3'] or '',
IngredientExtra = args[data[lang]['IngredientExtra']..'3'] or '',
ingredientExtra = args[i18n[lang]['IngredientExtra']..'3'] or '',
CraftResult = args[data[lang]['TitleResult']..'3'] or '',
craftResult = args[i18n[lang]['TitleResult']..'3'] or '',
}
}
}
}


local CSs = { '','','' }
local css = { '', '', '' }
local CSCategory = ''
local csCategory = ''
local Ings = { '','','' }
local ingredients = { '', '', '' }
local Results = { '','','' }
local results = { '', '', '' }


for tableNum = 1, 3 ,1 do
for tableNum = 1, 3 do
local recipe = recipes[tableNum]


if isBlank(Recipe[tableNum].CraftingStation) then
if isBlank(recipe.craftingStation) then
if tableNum == 1 then CSs[1] = data[lang]['ErrorCraftingStation'] end
if tableNum == 1 then css[1] = i18n[lang]['ErrorCraftingStation'] end
else
else
local v = {} ; v = mw.text.split(Recipe[tableNum].CraftingStation,'%s*,%s*')
local craftingStations = mw.text.split(recipe.craftingStation, '%s*,%s*')
f:callParserFunction('#Set','CraftingStation'..tableNum,Recipe[tableNum].CraftingStation)
if tableNum == 1 then
for i, item in ipairs(v) do
f:callParserFunction('#Set','CraftingStation', recipe.craftingStation)
 
else
if i > 1 then CSs[tableNum] = CSs[tableNum]..'<br />' end
f:callParserFunction('#Set','CraftingStation'..tableNum, recipe.craftingStation)
 
end
if isBlank(item) then
css[tableNum] = ''
CSs[tableNum] = CSs[tableNum]..data[lang]['BlankValue']
for i, item in ipairs(craftingStations) do
else
if i > 1 then css[tableNum] = css[tableNum]..'<br />' end
CSs[tableNum] = CSs[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,size=imgsize}}
css[tableNum] = css[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{item,size=imgsize})
if title.nsText == 'Elin' then
if title.nsText == 'Elin' then csCategory = csCategory..'[[Category:Elin '..item..']]' end
CSCategory = CSCategory..'[[Category:Elin '..item..']]'
end
end
end
end
end
end


if isBlank(Recipe[tableNum].Ingredient) then
if isBlank(recipe.ingredient) then
if tableNum == 1 then Ings[1] = data[lang]['ErrorIngredient'] end
if tableNum == 1 then ingredients[1] = i18n[lang]['ErrorIngredient'] end
else
else
local Ing = {} ; Ing = mw.text.split(Recipe[tableNum].Ingredient,'%s*,%s*')
local ingredientItems = mw.text.split(recipe.ingredient, '%s*,%s*')
local IngN = {} ; IngN = mw.text.split(Recipe[tableNum].IngredientNum,'%s*,%s*')
local ingredientNums = mw.text.split(recipe.ingredientNum, '%s*,%s*') or {}
local IngE = {} ; IngE = mw.text.split(Recipe[tableNum].IngredientExtra,'%s*,%s*') or ''
local ingredientExtras = mw.text.split(recipe.ingredientExtra, '%s*,%s*') or {}
f:callParserFunction('#Set','Ingredient'..tableNum,Recipe[tableNum].Ingredient)
if tableNum == 1 then
f:callParserFunction('#Set','IngredientNum'..tableNum,Recipe[tableNum].IngredientNum)
f:callParserFunction('#Set','Ingredient', recipe.ingredient)
f:callParserFunction('#Set','IngredientExtra'..tableNum,Recipe[tableNum].IngredientExtra)
f:callParserFunction('#Set','IngredientNum', recipe.ingredientNum)
for i, item in ipairs(Ing) do
f:callParserFunction('#Set','IngredientExtra', recipe.ingredientExtra)
 
else
f:callParserFunction('#Set','Ingredient'..tableNum, recipe.ingredient)
f:callParserFunction('#Set','IngredientNum'..tableNum, recipe.ingredientNum)
f:callParserFunction('#Set','IngredientExtra'..tableNum, recipe.ingredientExtra)
end
ingredients[tableNum] = ''
for i, item in ipairs(ingredientItems) do
if i > 1 then
if i > 1 then
Ings[tableNum] = Ings[tableNum]..'<div class="plus or-separator">&plus;</div>'
ingredients[tableNum] = ingredients[tableNum]..'<div class="plus or-separator">&plus;</div>'
end
end
local itemName, itemVar = item:match('([^@]+)@([^@]+)')
local itemNum = ingredientNums[i]
local itemExt = ingredientExtras[i]


if isBlank(item) then
if string.find(item, '/') then
Ings[tableNum] = Ings[tableNum]..data[lang]['BlankValue']
local subItems = mw.text.split(item, '%s*/%s*')
else
local subNums = ingredientNums[i] and mw.text.split(ingredientNums[i], '%s*/%s*') or {}
if string.find(item,'/') then
local subExtras = ingredientExtras[i] and mw.text.split(ingredientExtras[i], '%s*/%s*') or {}
local z = {} ; z = mw.text.split(Ing[i],'%s*/%s*')
for j, subItem in ipairs(subItems) do
local z2 = {} ; if IngN[i] then z2 = mw.text.split(IngN[i],'%s*/%s*') or 1 end
if j > 1 then
local z3 = {} ; if IngE[i] then z3 = mw.text.split(IngE[i],'%s*/%s*') or '' end
ingredients[tableNum] = ingredients[tableNum]..'<div class="or-separator">'..i18n[lang]['Or']..'</div>'
 
end
for i2, item2 in ipairs(z) do
local subItemName, subItemVar = subItem:match('([^@]+)@([^@]+)')
 
local subItemNum = subNums[j] or 1
local itemname = item2
local subItemExt = subExtras[j] or ''
local itemnum = z2[i2] or 1
if subItemVar then
local itemvar
if not subItemNum then
local itemext = z3[i2] or ''
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,v=subItemVar,link='Elin:'..subItemName..' '..subItemVar,size=imgsize})
 
else
if i2 > 1 then
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,subItemNum,v=subItemVar,link='Elin:'..subItemName..' '..subItemVar,size=imgsize})
Ings[tableNum] = Ings[tableNum]..'<div class="or-separator">'..data[lang]['Or']..'</div>'
end
 
if string.find(item2,'@') then
local v2 = {} ; v2 = mw.text.split(item2,'%s*@%s*')
itemname = v2[1]
itemvar = v2[2]
end
end
 
else
if isBlank(itemnum) then
if not subItemNum then
if itemvar then
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItem,size=imgsize})
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,v=itemvar,link='Elin:'..itemname..' '..itemvar,size=imgsize}}
else
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,size=imgsize}}
end
else
else
if itemvar then
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItem,subItemNum,size=imgsize})
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,itemnum,v=itemvar,link='Elin:'..itemname..' '..itemvar,size=imgsize}}
else
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,itemnum,size=imgsize}}
end
end
end
if itemext == data[lang]['TitleExtra'] then Ings[tableNum] = Ings[tableNum]..data[lang]['TextExtra']
elseif itemext == data[lang]['TitleGourmet'] then Ings[tableNum] = Ings[tableNum]..data[lang]['TextGourmet'] end
end
end
 
if subItemExt == i18n[lang]['TitleExtra'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextExtra']
elseif string.find(item,'@') then
elseif subItemExt == i18n[lang]['TitleGourmet'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextGourmet'] end
local v2 = {} ; v2 = mw.text.split(item,'%s*@%s*')
end
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={v2[1],v=v2[2],link='Elin:'..v2[1]..' '..v2[2],size=imgsize}}
elseif itemVar then
elseif isBlank(IngN[i]) then
if not itemNum then
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,size=imgsize}}
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{itemName,v=itemVar,link='Elin:'..itemName..' '..itemVar,size=imgsize})
else
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{itemName,itemNum,v=itemVar,link='Elin:'..itemName..' '..itemVar,size=imgsize})
end
else
if not itemNum then
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{item,size=imgsize})
else
else
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,IngN[i],size=imgsize}}
ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{item,itemNum,size=imgsize})
end
end
if IngE[i] == data[lang]['TitleExtra'] then Ings[tableNum] = Ings[tableNum]..data[lang]['TextExtra']
elseif IngE[i] ==  data[lang]['TitleGourmet'] then Ings[tableNum] = Ings[tableNum]..data[lang]['TextGourmet'] end
end
end
if itemExt == i18n[lang]['TitleExtra'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextExtra']
elseif itemExt == i18n[lang]['TitleGourmet'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextGourmet'] end
end
end
end
end


if isBlank(Recipe[tableNum].CraftResult) then
if not isBlank(recipe.craftResult) then
else
f:callParserFunction('#Set','CraftingResult'..tableNum, recipe.craftResult)
f:callParserFunction('#Set','CraftingResult'..tableNum, Recipe[tableNum].CraftResult)
local resultItems = mw.text.split(recipe.craftResult, '%s*,%s*')
local itemtable = {} ; itemtable = mw.text.split(Recipe[tableNum].CraftResult,'%s*,%s*')
results[tableNum] = ''
for i, item in ipairs(itemtable) do
for i, item in ipairs(resultItems) do
 
if i > 1 then
if i > 1 then
Results[tableNum] = Results[tableNum]..'<div class="or-separator">'..data[lang]['Or']..'</div>'
results[tableNum] = results[tableNum]..'<div class="or-separator">'..i18n[lang]['Or']..'</div>'
end
 
local itemname = item
local itemnum = 1
local itemvar
if string.find(itemname,'/') then
local z = {} ; z = mw.text.split(itemname,'%s*/%s*')
itemname = z[1]
itemnum = z[2]
if string.find(itemname,'@') then
local z = {} ; z = mw.text.split(itemname,'%s*@%s*')
itemname = z[1]
itemvar = z[2]
end
elseif string.find(itemname,'@') then
local z = {} ; z = mw.text.split(itemname,'%s*@%s*')
itemname = z[1]
itemvar = z[2]
end
 
if itemvar then
Results[tableNum] = Results[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,itemnum,v=itemvar,link='Elin:'..itemname..' '..itemvar,size=imgsize}}
else
Results[tableNum] = Results[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,itemnum,size=imgsize}}
end
end
        local subItemName = item
local subItemVar
local subItemNum = 1
        local match1 = item:match('([^@]+)@([^/]+)/([^/]+)')
        local match2 = item:match('([^@]+)@([^@]+)')
        local match3 = item:match('([^/]+)/([^/]+)')
        if match1 then
          subItemName, subItemVar, subItemNum = item:match('([^@]+)@([^/]+)/([^/]+)')
        elseif match2 then
          subItemName, subItemVar = item:match('([^@]+)@([^@]+)')
        elseif match3 then
          subItemName, subItemNum = item:match('([^/]+)/([^/]+)')
        end
        if match1 or match2 then
          results[tableNum] = results[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,subItemNum,v=subItemVar,link='Elin:'..subItemName..' '..subItemVar,size=imgsize})
        else
          results[tableNum] = results[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,subItemNum,size=imgsize})
        end
end
end
end
end
end
end


 
local craftingSkill = args[i18n[lang]['CraftSkill']]
local Craftingskill = args[data[lang]['CraftSkill']] or nil
local craftingSkillLv = args[i18n[lang]['CraftSkillLv']]
local CraftingskillLv = args[data[lang]['CraftSkillLv']] or nil


local html = mw.html.create('p')
local html = mw.html.create('p')
local div = html:tag('div'):addClass('CraftingTable'):cssText('float: left; display: ruby;')
local div=html:tag('div'):addClass('CraftingTable'):cssText('float: left; display: ruby;')
local table = div:tag('table'):addClass('wikitable')
local table = div:tag('table'):addClass('wikitable')
if not Craftingskill and not CraftingskillLv then
else
local Skills = ''


if isBlank(Craftingskill) then
if craftingSkill or craftingSkillLv then
Skills = '?'..data[lang]['TitleSkill']
local skills = (isBlank(craftingSkill) and '?' or craftingSkill)..i18n[lang]['TitleSkill']..'&nbsp;'..(isBlank(craftingSkillLv) and 'Lv.?' or 'Lv.'..craftingSkillLv)
else
f:callParserFunction('#Set','CraftingSkill', craftingSkill)
Skills = Craftingskill..data[lang]['TitleSkill']
f:callParserFunction('#Set','CraftingSkillLv', craftingSkillLv)
f:callParserFunction('#Set','CraftingSkill',Craftingskill)
table:tag('tr'):tag('th'):attr('colspan', results[1] ~= '' and 3 or 2):wikitext(skills)
end
 
for tableNum = 1, 3 do
if css[tableNum] ~= '' or ingredients[tableNum] ~= '' or results[tableNum] ~= '' then
if tableNum > 1 then
table = div:tag('table'):addClass('wikitable'):cssText('margin-left:1em;')
end
end
 
local tr1 = table:tag('tr')
Skills = Skills..'&nbsp;'
tr1:tag('th'):wikitext(i18n[lang]['TitleCraftingStation'])
 
tr1:tag('th'):wikitext(i18n[lang]['TitleIngredient'])
if isBlank(CraftingskillLv) then
if results[tableNum] ~= '' then
Skills = Skills..'Lv.?'
tr1:tag('th'):wikitext(i18n[lang]['TitleResult'])
else
Skills = Skills..'Lv.'..CraftingskillLv
f:callParserFunction('#Set','CraftingSkillLv',CraftingskillLv)
end
end
 
local tr2 = table:tag('tr')
if Results ~= '' then colspan = 3
tr2:tag('td'):wikitext(css[tableNum])
else colspan = 2 end
tr2:tag('td'):cssText('text-align: center;'):wikitext(ingredients[tableNum])
table:tag('tr'):tag('th'):attr('colspan',colspan):wikitext(Skills)
if results[tableNum] ~= '' then
end
tr2:tag('td'):cssText('text-align: center;'):wikitext(results[tableNum])
 
for tableNum = 1, 3 ,1 do
if CSs[tableNum] ~= '' or Ings[tableNum] ~= '' or Results[tableNum] ~= '' then
if tableNum > 1 then
table = div:tag('table'):addClass('wikitable'):cssText('margin-left:1em;')
end
local tr1 = table:tag('tr')
tr1:tag('th'):wikitext(data[lang]['TitleCraftingStation'])
tr1:tag('th'):wikitext(data[lang]['TitleIngredient'])
if Results[tableNum] ~= '' then
tr1:tag('th'):wikitext(data[lang]['TitleResult'])
end
local tr2 = table:tag('tr')
tr2:tag('td'):wikitext(CSs[tableNum])
tr2:tag('td'):cssText('text-align: center;'):wikitext(Ings[tableNum])
if Results[tableNum] ~= '' then
tr2:tag('td'):cssText('text-align: center;'):wikitext(Results[tableNum])
end
end
end
end
end
end


html:wikitext(string.format('<div style="clear:both;"></div>'))
html:wikitext('<div style="clear:both;"></div>')


local CraftBonus = args[data[lang]['CraftBonus']] or nil
local craftBonus = args[i18n[lang]['CraftBonus']]
if isBlank(CraftBonus) then
if isBlank(craftBonus) then
else
else
html:tag('li'):wikitext(string.format('<b>'..data[lang]['TitleCraftBonus']..'</b> : '..CraftBonus)):done()
html:tag('li'):wikitext('<b>'..i18n[lang]['TitleCraftBonus']..'</b> : '..craftBonus):done()
f:callParserFunction('#Set','CraftBonus',CraftBonus)
f:callParserFunction('#Set','CraftBonus', craftBonus)
end
end


local ObtainRecipe = args[data[lang]['ObtainRecipe']] or nil
local obtainRecipe = args[i18n[lang]['ObtainRecipe']]
if isBlank(ObtainRecipe) then
if isBlank(obtainRecipe) then
else
else
html:tag('li'):wikitext(string.format('<b>'..data[lang]['TitleObtainRecipe']..'</b> : '..ObtainRecipe)):done()
html:tag('li'):wikitext('<b>'..i18n[lang]['TitleObtainRecipe']..'</b> : '..obtainRecipe):done()
f:callParserFunction('#Set','ObtainRecipe',ObtainRecipe)
f:callParserFunction('#Set','ObtainRecipe', obtainRecipe)
end
end


if title.nsText == 'Elin' then
if title.nsText == 'Elin' then
html:wikitext(string.format(data[lang]['Category']))
html:wikitext(i18n[lang]['Category'])
if isBlank(CSCategory) then
if csCategory ~= '' then
else
html:wikitext(csCategory)
html:wikitext(CSCategory)
end
end
end
end


return tostring(html)
return tostring(html)

Latest revision as of 14:23, 31 March 2025

Documentation for this module may be created at Module:CraftingTable/doc

local p = {}

local function isBlank(value)
	return value == nil or not value or value == ''
end

local function TSafely(f, templateName, args)
	local result = f:expandTemplate{ title=templateName, args=args }
	if not result then
		mw.log('Template '..templateName..' expansion failed')
		return ''
	end
	return result
end

function p.crafttable(f)
	local args = f:getParent().args
	local lang = f.args[1]
	local i18n = mw.loadData('Module:CraftingTable/i18n') or {}
	local title = mw.title.getCurrentTitle()
	local recipes = {
		{
			craftingStation = args[i18n[lang]['CraftingStation']] or '',
			ingredient = args[i18n[lang]['Ingredient']] or '',
			ingredientNum = args[i18n[lang]['IngredientNum']] or '',
			ingredientExtra = args[i18n[lang]['IngredientExtra']] or '',
			craftResult = args[i18n[lang]['TitleResult']] or '',
		},
		{
			craftingStation = args[i18n[lang]['CraftingStation']..'2'] or '',
			ingredient = args[i18n[lang]['Ingredient']..'2'] or '',
			ingredientNum = args[i18n[lang]['IngredientNum']..'2'] or '',
			ingredientExtra = args[i18n[lang]['IngredientExtra']..'2'] or '',
			craftResult = args[i18n[lang]['TitleResult']..'2'] or '',
		},
		{
			craftingStation = args[i18n[lang]['CraftingStation']..'3'] or '',
			ingredient = args[i18n[lang]['Ingredient']..'3'] or '',
			ingredientNum = args[i18n[lang]['IngredientNum']..'3'] or '',
			ingredientExtra = args[i18n[lang]['IngredientExtra']..'3'] or '',
			craftResult = args[i18n[lang]['TitleResult']..'3'] or '',
		}
	}

	local css = { '', '', '' }
	local csCategory = ''
	local ingredients = { '', '', '' }
	local results = { '', '', '' }

	for tableNum = 1, 3 do
		local recipe = recipes[tableNum]

		if isBlank(recipe.craftingStation) then
			if tableNum == 1 then css[1] = i18n[lang]['ErrorCraftingStation'] end
		else
			local craftingStations = mw.text.split(recipe.craftingStation, '%s*,%s*')
			if tableNum == 1 then
				f:callParserFunction('#Set','CraftingStation', recipe.craftingStation)
			else
				f:callParserFunction('#Set','CraftingStation'..tableNum, recipe.craftingStation)
			end
			css[tableNum] = ''
			for i, item in ipairs(craftingStations) do
				if i > 1 then css[tableNum] = css[tableNum]..'<br />' end
				css[tableNum] = css[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{item,size=imgsize})
				if title.nsText == 'Elin' then csCategory = csCategory..'[[Category:Elin '..item..']]' end
			end
		end

		if isBlank(recipe.ingredient) then
			if tableNum == 1 then ingredients[1] = i18n[lang]['ErrorIngredient'] end
		else
			local ingredientItems = mw.text.split(recipe.ingredient, '%s*,%s*')
			local ingredientNums = mw.text.split(recipe.ingredientNum, '%s*,%s*') or {}
			local ingredientExtras = mw.text.split(recipe.ingredientExtra, '%s*,%s*') or {}
			if tableNum == 1 then
				f:callParserFunction('#Set','Ingredient', recipe.ingredient)
				f:callParserFunction('#Set','IngredientNum', recipe.ingredientNum)
				f:callParserFunction('#Set','IngredientExtra', recipe.ingredientExtra)
			else
				f:callParserFunction('#Set','Ingredient'..tableNum, recipe.ingredient)
				f:callParserFunction('#Set','IngredientNum'..tableNum, recipe.ingredientNum)
				f:callParserFunction('#Set','IngredientExtra'..tableNum, recipe.ingredientExtra)
			end
			ingredients[tableNum] = ''
			for i, item in ipairs(ingredientItems) do
				if i > 1 then
					ingredients[tableNum] = ingredients[tableNum]..'<div class="plus or-separator">&plus;</div>'
				end
				local itemName, itemVar = item:match('([^@]+)@([^@]+)')
				local itemNum = ingredientNums[i]
				local itemExt = ingredientExtras[i]

				if string.find(item, '/') then
					local subItems = mw.text.split(item, '%s*/%s*')
					local subNums = ingredientNums[i] and mw.text.split(ingredientNums[i], '%s*/%s*') or {}
					local subExtras = ingredientExtras[i] and mw.text.split(ingredientExtras[i], '%s*/%s*') or {}
					for j, subItem in ipairs(subItems) do
						if j > 1 then
							ingredients[tableNum] = ingredients[tableNum]..'<div class="or-separator">'..i18n[lang]['Or']..'</div>'
						end
						local subItemName, subItemVar = subItem:match('([^@]+)@([^@]+)')
						local subItemNum = subNums[j] or 1
						local subItemExt = subExtras[j] or ''
						if subItemVar then
							if not subItemNum then
								ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,v=subItemVar,link='Elin:'..subItemName..' '..subItemVar,size=imgsize})
							else
								ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,subItemNum,v=subItemVar,link='Elin:'..subItemName..' '..subItemVar,size=imgsize})
							end
						else
							if not subItemNum then
								ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItem,size=imgsize})
							else
								ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItem,subItemNum,size=imgsize})
							end
						end
						if subItemExt == i18n[lang]['TitleExtra'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextExtra']
						elseif subItemExt == i18n[lang]['TitleGourmet'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextGourmet'] end
					end
				elseif itemVar then
					if not itemNum then
						ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{itemName,v=itemVar,link='Elin:'..itemName..' '..itemVar,size=imgsize})
					else
						ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{itemName,itemNum,v=itemVar,link='Elin:'..itemName..' '..itemVar,size=imgsize})
					end
				else
					if not itemNum then
						ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{item,size=imgsize})
					else
						ingredients[tableNum] = ingredients[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{item,itemNum,size=imgsize})
					end
				end
				if itemExt == i18n[lang]['TitleExtra'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextExtra']
				elseif itemExt == i18n[lang]['TitleGourmet'] then ingredients[tableNum] = ingredients[tableNum]..i18n[lang]['TextGourmet'] end
			end
		end

		if not isBlank(recipe.craftResult) then
			f:callParserFunction('#Set','CraftingResult'..tableNum, recipe.craftResult)
			local resultItems = mw.text.split(recipe.craftResult, '%s*,%s*')
			results[tableNum] = ''
			for i, item in ipairs(resultItems) do
				if i > 1 then
					results[tableNum] = results[tableNum]..'<div class="or-separator">'..i18n[lang]['Or']..'</div>'
				end
        local subItemName = item
				local subItemVar
				local subItemNum = 1
        local match1 = item:match('([^@]+)@([^/]+)/([^/]+)')
        local match2 = item:match('([^@]+)@([^@]+)')
        local match3 = item:match('([^/]+)/([^/]+)')
        if match1 then
          subItemName, subItemVar, subItemNum = item:match('([^@]+)@([^/]+)/([^/]+)')
        elseif match2 then
          subItemName, subItemVar = item:match('([^@]+)@([^@]+)')
        elseif match3 then
          subItemName, subItemNum = item:match('([^/]+)/([^/]+)')
        end
        if match1 or match2 then
          results[tableNum] = results[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,subItemNum,v=subItemVar,link='Elin:'..subItemName..' '..subItemVar,size=imgsize})
        else
          results[tableNum] = results[tableNum]..TSafely(f,i18n[lang]['TemplateName'],{subItemName,subItemNum,size=imgsize})
        end
			end
		end
	end

	local craftingSkill = args[i18n[lang]['CraftSkill']]
	local craftingSkillLv = args[i18n[lang]['CraftSkillLv']]

	local html = mw.html.create('p')
	local div=html:tag('div'):addClass('CraftingTable'):cssText('float: left; display: ruby;')
	local table = div:tag('table'):addClass('wikitable')

	if craftingSkill or craftingSkillLv then
		local skills = (isBlank(craftingSkill) and '?' or craftingSkill)..i18n[lang]['TitleSkill']..'&nbsp;'..(isBlank(craftingSkillLv) and 'Lv.?' or 'Lv.'..craftingSkillLv)
		f:callParserFunction('#Set','CraftingSkill', craftingSkill)
		f:callParserFunction('#Set','CraftingSkillLv', craftingSkillLv)
		table:tag('tr'):tag('th'):attr('colspan', results[1] ~= '' and 3 or 2):wikitext(skills)
	end

	for tableNum = 1, 3 do
		if css[tableNum] ~= '' or ingredients[tableNum] ~= '' or results[tableNum] ~= '' then
			if tableNum > 1 then
				table = div:tag('table'):addClass('wikitable'):cssText('margin-left:1em;')
			end
			local tr1 = table:tag('tr')
			tr1:tag('th'):wikitext(i18n[lang]['TitleCraftingStation'])
			tr1:tag('th'):wikitext(i18n[lang]['TitleIngredient'])
			if results[tableNum] ~= '' then
				tr1:tag('th'):wikitext(i18n[lang]['TitleResult'])
			end
			local tr2 = table:tag('tr')
			tr2:tag('td'):wikitext(css[tableNum])
			tr2:tag('td'):cssText('text-align: center;'):wikitext(ingredients[tableNum])
			if results[tableNum] ~= '' then
				tr2:tag('td'):cssText('text-align: center;'):wikitext(results[tableNum])
			end
		end
	end

	html:wikitext('<div style="clear:both;"></div>')

	local craftBonus = args[i18n[lang]['CraftBonus']]
	if isBlank(craftBonus) then
	else
		html:tag('li'):wikitext('<b>'..i18n[lang]['TitleCraftBonus']..'</b> : '..craftBonus):done()
		f:callParserFunction('#Set','CraftBonus', craftBonus)
	end

	local obtainRecipe = args[i18n[lang]['ObtainRecipe']]
	if isBlank(obtainRecipe) then
	else
		html:tag('li'):wikitext('<b>'..i18n[lang]['TitleObtainRecipe']..'</b> : '..obtainRecipe):done()
		f:callParserFunction('#Set','ObtainRecipe', obtainRecipe)
	end

	if title.nsText == 'Elin' then
		html:wikitext(i18n[lang]['Category'])
		if csCategory ~= '' then
			html:wikitext(csCategory)
		end
	end

	return tostring(html)
	
end

return p