Module:Materials

local p = {} data = mw.loadData("Module:Materials/Data")

local function getArgs(frame) local args = {} for key, value in pairs(frame:getParent.args) do       args[key] = value end for key, value in pairs(frame.args) do       args[key] = value end return args end

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 '' if game == "PC" then return p.outputMaterialPC(material, num, nb, size) elseif game == "NH" then return p.outputMaterialNH(material, num, nb, size) end end

function p.outputMaterialNH(material, num, nb, size) 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 print = print ..  .. data.materialNH[material][4] ..  else if not isEmpty(data.materialNH[material]) and not isEmpty(data.materialNH[material][5]) then print = print .. data.materialNH[material][5] else print = print ..  .. material ..  end end print = print .. ' '	if not isEmpty(nb) then print = print .. ''	else print = print .. ' '	end return print end

function p.outputMaterialPC (material, num, nb, size) 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