Module:CraftingTable: Difference between revisions

From Ylvapedia
No edit summary
No edit summary
Line 1: Line 1:
local p = {}
local p = {}
local function isBlank(value)
return value == nil or not value or value == ''
end


function p.crafttable(f)
function p.crafttable(f)
Line 31: Line 35:
}
}


local CSs = { '', '', '' }
local CSs = { '','','' }
local CSCategory = ''
local CSCategory = ''
local Ings = { '', '', '' }
local Ings = { '','','' }
local Results = { '', '', '' }
local Results = { '','','' }


for n = 1, 3 ,1 do
for tableNum = 1, 3 ,1 do


if not Recipe[n].CraftingStation or Recipe[n].CraftingStation == '' then
if isBlank(Recipe[tableNum].CraftingStation) then
if n == 1 then CSs[1] = data[lang]['ErrorCraftingStation'] end
if tableNum == 1 then CSs[1] = data[lang]['ErrorCraftingStation'] end
else
else
local v = {} ; v = mw.text.split(Recipe[n].CraftingStation, "%s*,%s*")
local v = {} ; v = mw.text.split(Recipe[tableNum].CraftingStation,'%s*,%s*')
f:callParserFunction( '#Set', 'CraftingStation', Recipe[n].CraftingStation )
f:callParserFunction('#Set','CraftingStation'..tableNum,Recipe[tableNum].CraftingStation)
for i, item in ipairs(v) do
for i, item in ipairs(v) do


if i > 1 then CSs[n] = CSs[n] .. '<br />' end
if i > 1 then CSs[tableNum] = CSs[tableNum]..'<br />' end


if not item or item == '' then
if isBlank(item) then
CSs[n] = CSs[n] .. data[lang]['BlankValue']
CSs[tableNum] = CSs[tableNum]..data[lang]['BlankValue']
else
else
CSs[n] = CSs[n] .. f:expandTemplate{ title = data[lang]['TemplateName'], args = { item,size=imgsize } }
CSs[tableNum] = CSs[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,size=imgsize}}
if title.nsText == "Elin" then
if title.nsText == 'Elin' then
CSCategory = CSCategory..'[[Category:Elin '..item..']]'
CSCategory = CSCategory..'[[Category:Elin '..item..']]'
end
end
Line 58: Line 62:
end
end


if not Recipe[n].Ingredient or Recipe[n].Ingredient == '' then
if isBlank(Recipe[tableNum].Ingredient) then
if n == 1 then Ings[1] = data[lang]['ErrorIngredient'] end
if tableNum == 1 then Ings[1] = data[lang]['ErrorIngredient'] end
else
else
local v = {} ; v = mw.text.split(Recipe[n].Ingredient, "%s*,%s*")
local Ing = {} ; Ing = mw.text.split(Recipe[tableNum].Ingredient,'%s*,%s*')
local x = {} ; x = mw.text.split(Recipe[n].IngredientNum, "%s*,%s*")
local IngN = {} ; IngN = mw.text.split(Recipe[tableNum].IngredientNum,'%s*,%s*')
local y = {} ; y = mw.text.split(Recipe[n].IngredientExtra, "%s*,%s*")
local IngE = {} ; IngE = mw.text.split(Recipe[tableNum].IngredientExtra,'%s*,%s*') or ''
f:callParserFunction( '#Set', 'Ingredient', Recipe[n].Ingredient )
f:callParserFunction('#Set','Ingredient'..tableNum,Recipe[tableNum].Ingredient)
f:callParserFunction( '#Set', 'IngredientNum', Recipe[n].IngredientNum )
f:callParserFunction('#Set','IngredientNum'..tableNum,Recipe[tableNum].IngredientNum)
f:callParserFunction( '#Set', 'IngredientExtra', Recipe[n].IngredientExtra )
f:callParserFunction('#Set','IngredientExtra'..tableNum,Recipe[tableNum].IngredientExtra)
for i, item in ipairs(v) do
for i, item in ipairs(Ing) do


if i > 1 then
if i > 1 then
Ings[n] = Ings[n] .. '<div class="plus or-separator">&plus;</div>'
Ings[tableNum] = Ings[tableNum]..'<div class="plus or-separator">&plus;</div>'
end
end


if not item or item == '' then
if isBlank(item) then
Ings[n] = Ings[n] .. data[lang]['BlankValue']
Ings[tableNum] = Ings[tableNum]..data[lang]['BlankValue']
else
else
local z = string.find(item, "/")
if string.find(item,'/') then
if z then
local z = {} ; z = mw.text.split(Ing[i],'%s*/%s*')
local z = {} ; z = mw.text.split(item, "%s*/%s*")
local z2 = {} ; if IngN[i] then z2 = mw.text.split(IngN[i],'%s*/%s*') or 1 end
local z2 = {} ; z2 = mw.text.split(x[i], "%s*/%s*") or 1
local z3 = {} ; if IngE[i] then z3 = mw.text.split(IngE[i],'%s*/%s*') or '' end
local z3 = {} ; z3 = mw.text.split(y[i], "%s*/%s*") or ''
 
for i2, item2 in ipairs(z) do
for i2, item2 in ipairs(z) do
local itemname = item2
local itemnum = z2[i2] or 1
local itemvar
local itemext = z3[i2] or ''
if i2 > 1 then
if i2 > 1 then
Ings[n] = Ings[n] .. '<div class="or-separator">'..data[lang]['Or']..'</div>'
Ings[tableNum] = Ings[tableNum]..'<div class="or-separator">'..data[lang]['Or']..'</div>'
end
end
if z2[i2] == '' then
 
Ings[n] = Ings[n] .. f:expandTemplate{ title = data[lang]['TemplateName'], args = { item2,size=imgsize } }
if string.find(item2,'@') then
else
local v2 = {} ; v2 = mw.text.split(item2,'%s*@%s*')
Ings[n] = Ings[n] .. f:expandTemplate{ title = data[lang]['TemplateName'], args = { item2,z2[i2],size=imgsize } }
itemname = v2[1]
itemvar = v2[2]
end
end


if z3[i2] == data[lang]['TitleExtra'] then
if isBlank(itemnum) then
Ings[n] = Ings[n] .. data[lang]['TextExtra']
if itemvar then
elseif z3[i2] ==  data[lang]['TitleGourmet'] then
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,v=itemvar,link='Elin:'..itemname..' '..itemvar,size=imgsize}}
Ings[n] = Ings[n] .. data[lang]['TextGourmet']
else
end
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,size=imgsize}}
end
end
else
local v2 = string.find(item, "@")
if v2 then
local v2 = {} ; v2 = mw.text.split(item, "%s*@%s*")
Ings[n] = Ings[n] .. f:expandTemplate{ title = data[lang]['TemplateName'], args = { v2[1],v=v2[2],size=imgsize } }
else
if x[i] == '' then
Ings[n] = Ings[n] .. f:expandTemplate{ title = data[lang]['TemplateName'], args = { item,size=imgsize } }
else
else
Ings[n] = Ings[n] .. f:expandTemplate{ title = data[lang]['TemplateName'], args = { item,x[i],size=imgsize } }
if itemvar then
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 y[i] == data[lang]['TitleExtra'] then
elseif string.find(item,'@') then
Ings[n] = Ings[n] .. data[lang]['TextExtra']
local v2 = {} ; v2 = mw.text.split(item,'%s*@%s*')
elseif y[i] == data[lang]['TitleGourmet'] then
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={v2[1],v=v2[2],link='Elin:'..v2[1]..' '..v2[2],size=imgsize}}
Ings[n] = Ings[n] .. data[lang]['TextGourmet']
elseif isBlank(IngN[i]) then
end
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,size=imgsize}}
else
Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,IngN[i],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
end
end
end
end


if not Recipe[n].CraftResult or Recipe[n].CraftResult == '' then
if isBlank(Recipe[tableNum].CraftResult) then
else
else
z = string.find(Recipe[n].CraftResult, "%s*/%s*")
f:callParserFunction('#Set','CraftingResult'..tableNum, Recipe[tableNum].CraftResult)
f:callParserFunction( '#Set', 'CraftingResult', Recipe[n].CraftResult )
local itemtable = {} ; itemtable = mw.text.split(Recipe[tableNum].CraftResult,'%s*,%s*')
if z then
for i, item in ipairs(itemtable) do
local x = {} ; x = mw.text.split(Recipe[n].CraftResult, "%s*/%s*")
 
local x2 = string.find(Recipe[n].CraftResult, "@")
if i > 1 then
if x2 then
Results[tableNum] = Results[tableNum]..'<div class="or-separator">'..data[lang]['Or']..'</div>'
local x2 = {} ; x2 = mw.text.split(x[1], "%s*@%s*")
end
Results[n] = f:expandTemplate{ title = data[lang]['TemplateName'], args = { x2[1],x[2],v=x2[2],link='Elin:'..x2[1]..' '..x2[2],size=imgsize } }
 
else
local itemname = item
Results[n] = f:expandTemplate{ title = data[lang]['TemplateName'], args = { x[1],x[2],size=imgsize } }
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
end
else
 
local x = string.find(Recipe[n].CraftResult, "@")
if itemvar then
if x then
Results[tableNum] = Results[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,itemnum,v=itemvar,link='Elin:'..itemname..' '..itemvar,size=imgsize}}
local x = {} ; x = mw.text.split(Recipe[n].CraftResult, "%s*@%s*")
Results[n] = f:expandTemplate{ title = data[lang]['TemplateName'], args = { x[1],v=x[2],link='Elin:'..x[1]..' '..x[2],size=imgsize } }
else
else
Results[n] = f:expandTemplate{ title = data[lang]['TemplateName'], args = { Recipe[n].CraftResult,size=imgsize } }
Results[tableNum] = Results[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={itemname,itemnum,size=imgsize}}
end
end
end
end
Line 156: Line 183:
local Skills = ''
local Skills = ''


if not Craftingskill then
if isBlank(Craftingskill) then
Skills = '?'..data[lang]['TitleSkill']
Skills = '?'..data[lang]['TitleSkill']
else
else
Skills = Craftingskill..data[lang]['TitleSkill']
Skills = Craftingskill..data[lang]['TitleSkill']
f:callParserFunction( '#Set', 'CraftingSkill', Craftingskill )
f:callParserFunction('#Set','CraftingSkill',Craftingskill)
end
end


Skills = Skills .. '&nbsp;'
Skills = Skills..'&nbsp;'


if not CraftingskillLv then
if isBlank(CraftingskillLv) then
Skills = Skills .. 'Lv.?'
Skills = Skills..'Lv.?'
else
else
Skills = Skills .. 'Lv.'.. CraftingskillLv
Skills = Skills..'Lv.'..CraftingskillLv
f:callParserFunction( '#Set', 'CraftingSkillLv', CraftingskillLv )
f:callParserFunction('#Set','CraftingSkillLv',CraftingskillLv)
end
end


Line 177: Line 204:
end
end


for n = 1, 3 ,1 do
for tableNum = 1, 3 ,1 do
if CSs[n] ~= '' or Ings[n] ~= '' or Results[n] ~= '' then
if CSs[tableNum] ~= '' or Ings[tableNum] ~= '' or Results[tableNum] ~= '' then
if n > 1 then
if tableNum > 1 then
table = div:tag('table'):addClass('wikitable'):cssText('margin-left:1em;')
table = div:tag('table'):addClass('wikitable'):cssText('margin-left:1em;')
end
end
Line 185: Line 212:
tr1:tag('th'):wikitext(data[lang]['TitleCraftingStation'])
tr1:tag('th'):wikitext(data[lang]['TitleCraftingStation'])
tr1:tag('th'):wikitext(data[lang]['TitleIngredient'])
tr1:tag('th'):wikitext(data[lang]['TitleIngredient'])
if Results[n] ~= '' then
if Results[tableNum] ~= '' then
tr1:tag('th'):wikitext(data[lang]['TitleResult'])
tr1:tag('th'):wikitext(data[lang]['TitleResult'])
end
end
local tr2 = table:tag('tr')
local tr2 = table:tag('tr')
tr2:tag('td'):wikitext(CSs[n])
tr2:tag('td'):wikitext(CSs[tableNum])
tr2:tag('td'):cssText('text-align: center;'):wikitext(Ings[n])
tr2:tag('td'):cssText('text-align: center;'):wikitext(Ings[tableNum])
if Results[n] ~= '' then
if Results[tableNum] ~= '' then
tr2:tag('td'):cssText('text-align: center;'):wikitext(Results[n])
tr2:tag('td'):cssText('text-align: center;'):wikitext(Results[tableNum])
end
end
end
end
Line 200: Line 227:


local CraftBonus = args[data[lang]['CraftBonus']] or nil
local CraftBonus = args[data[lang]['CraftBonus']] or nil
if not CraftBonus or 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(string.format('<b>'..data[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[data[lang]['ObtainRecipe']] or nil
if not ObtainRecipe or 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(string.format('<b>'..data[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(string.format(data[lang]['Category']))
end
if isBlank(CSCategory) then
 
else
if not CSCategory or CSCategory == '' then
html:wikitext(CSCategory)
else
end
html:wikitext(CSCategory)
end
end



Revision as of 16:07, 29 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

function p.crafttable(f)

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

	local CSs = { '','','' }
	local CSCategory = ''
	local Ings = { '','','' }
	local Results = { '','','' }

	for tableNum = 1, 3 ,1 do

		if isBlank(Recipe[tableNum].CraftingStation) then
			if tableNum == 1 then CSs[1] = data[lang]['ErrorCraftingStation'] end
		else
			local v = {} ; v = mw.text.split(Recipe[tableNum].CraftingStation,'%s*,%s*')
			f:callParserFunction('#Set','CraftingStation'..tableNum,Recipe[tableNum].CraftingStation)
			for i, item in ipairs(v) do

				if i > 1 then CSs[tableNum] = CSs[tableNum]..'<br />' end

				if isBlank(item) then
					CSs[tableNum] = CSs[tableNum]..data[lang]['BlankValue']
				else
					CSs[tableNum] = CSs[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,size=imgsize}}
					if title.nsText == 'Elin' then
						CSCategory = CSCategory..'[[Category:Elin '..item..']]'
					end
				end
			end
		end

		if isBlank(Recipe[tableNum].Ingredient) then
			if tableNum == 1 then Ings[1] = data[lang]['ErrorIngredient'] end
		else
			local Ing = {} ; Ing = mw.text.split(Recipe[tableNum].Ingredient,'%s*,%s*')
			local IngN = {} ; IngN = mw.text.split(Recipe[tableNum].IngredientNum,'%s*,%s*')
			local IngE = {} ; IngE = mw.text.split(Recipe[tableNum].IngredientExtra,'%s*,%s*') or ''
			f:callParserFunction('#Set','Ingredient'..tableNum,Recipe[tableNum].Ingredient)
			f:callParserFunction('#Set','IngredientNum'..tableNum,Recipe[tableNum].IngredientNum)
			f:callParserFunction('#Set','IngredientExtra'..tableNum,Recipe[tableNum].IngredientExtra)
			for i, item in ipairs(Ing) do

				if i > 1 then
					Ings[tableNum] = Ings[tableNum]..'<div class="plus or-separator">&plus;</div>'
				end

				if isBlank(item) then
					Ings[tableNum] = Ings[tableNum]..data[lang]['BlankValue']
				else
					if string.find(item,'/') then
						local z = {} ; z = mw.text.split(Ing[i],'%s*/%s*')
						local z2 = {} ; if IngN[i] then z2 = mw.text.split(IngN[i],'%s*/%s*') or 1 end
						local z3 = {} ; if IngE[i] then z3 = mw.text.split(IngE[i],'%s*/%s*') or '' end

						for i2, item2 in ipairs(z) do

							local itemname = item2
							local itemnum = z2[i2] or 1
							local itemvar
							local itemext = z3[i2] or ''

							if i2 > 1 then
								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

							if isBlank(itemnum) then
								if itemvar then
									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
								if itemvar then
									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

							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

					elseif string.find(item,'@') then
						local v2 = {} ; v2 = mw.text.split(item,'%s*@%s*')
						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 isBlank(IngN[i]) then
							Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,size=imgsize}}
					else
							Ings[tableNum] = Ings[tableNum]..f:expandTemplate{title=data[lang]['TemplateName'],args={item,IngN[i],size=imgsize}}
					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
		end

		if isBlank(Recipe[tableNum].CraftResult) then
		else
			f:callParserFunction('#Set','CraftingResult'..tableNum, Recipe[tableNum].CraftResult)
			local itemtable = {} ; itemtable = mw.text.split(Recipe[tableNum].CraftResult,'%s*,%s*')
			for i, item in ipairs(itemtable) do

				if i > 1 then
					Results[tableNum] = Results[tableNum]..'<div class="or-separator">'..data[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
		end
	end


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

	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 not Craftingskill and not CraftingskillLv then
		else
			local Skills = ''

			if isBlank(Craftingskill) then
				Skills = '?'..data[lang]['TitleSkill']
			else
				Skills = Craftingskill..data[lang]['TitleSkill']
				f:callParserFunction('#Set','CraftingSkill',Craftingskill)
			end

			Skills = Skills..'&nbsp;'

			if isBlank(CraftingskillLv) then
				Skills = Skills..'Lv.?'
			else
				Skills = Skills..'Lv.'..CraftingskillLv
				f:callParserFunction('#Set','CraftingSkillLv',CraftingskillLv)
			end

			if Results ~= '' then colspan = 3
			else colspan = 2 end
			table:tag('tr'):tag('th'):attr('colspan',colspan):wikitext(Skills)
		end

		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

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

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

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

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

	return tostring(html)
	
end

return p