Module:Materials

local p = {} local getArgs = require('Module:Arguments').getArgs local convertCase = require('Module:SentenceCase').firstToUpper checkCase = mw.loadData("Module:CapitalizationCheck/Data") data = mw.loadData("Module:Materials/Data")

function p.main(frame) local args     = getArgs(frame) local game     = args.game or '' local nb       = args.nb or '' local size     = args.size or '' local material = args[1] or args.material or '' local num      = args[2] or args.num or '' local sentenceCase = args[3] or args.sentencecase or '' if game == "PC" then return p.outputMaterialPC(material, num, nb, size, sentenceCase) elseif game == "NH" then return p.outputMaterialNH(material, num, nb, size, sentenceCase) end end

function p.outputMaterialNH(material, num, nb, size, sentenceCase) local function isEmpty(s) return s == nil or s == '' end local print = ' ' if not isEmpty(data.materialNH[material]) and not isEmpty(data.materialNH[material][1]) then print = print .. ' '	else print = print .. 'Leaf NH Icon cropped.png'		if not isEmpty(size) then			print = print .. ' ' end if not isEmpty(num) then print = print .. num .. '× '	else print = print .. ''	end if not isEmpty(data.materialNH[material]) and not isEmpty(data.materialNH[material][3]) then if not isEmpty(sentenceCase) then print = print ..  .. convertCase(data.materialNH[material][4]) ..  else print = print ..  .. data.materialNH[material][4] ..  end else if not isEmpty(data.materialNH[material]) and not isEmpty(data.materialNH[material][5]) then print = print .. data.materialNH[material][5] else if not isEmpty(sentenceCase) then print = print ..  .. convertCase(material) ..  else print = print ..  .. material ..  end end end print = print .. ' '	if not isEmpty(nb) then print = print .. ''	else print = print .. ' '	end -- Check capitalization if not isEmpty(checkCase.newHorizons[material:lower]) and material == checkCase.newHorizons[material:lower] then print = print .. ""	else print = print .. ""	end return print end

function p.outputMaterialPC (material, num, nb, size, sentenceCase) local function isEmpty(s) return s == nil or s == '' end local print = ' ' if not isEmpty(data.materialPC[material]) and not isEmpty(data.materialPC[material][1]) then print = print .. ' '	end if not isEmpty(num) then print = print .. num .. '× '	else print = print .. ''	end if not isEmpty(data.materialPC[material]) and not isEmpty(data.materialPC[material][3]) then print = print ..  .. data.materialPC[material][4] ..  else if not isEmpty(data.materialPC[material]) and not isEmpty(data.materialPC[material][5]) then print = print .. data.materialPC[material][5] else print = print ..  .. material ..  end end print = print .. ' '	if not isEmpty(nb) then print = print .. ''	else print = print .. ' '	end return print end return p