24,493 ARTICLES
ON THIS WIKI

Module:TConstruct/Material

< Module:TConstruct

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

local p = {}

local g = require("Module:Common")

-- returns MW code
function p.main(frame)
	local frame, args = g.getFrameAndArgs(frame)
	
	if not g.isGiven(args.name) then
		return ""
	end
	
	local out = g.smwProp("Is TiC material", args.name, " ")
	if g.isGiven(args.durability) and tonumber(args.durability) then
		out = out .. g.smwProp("Has TiC durability", tonumber(args.durability), " ")
	end
	if g.isGiven(args.minespeed) and tonumber(args.minespeed) then
		out = out .. g.smwProp("Has TiC mining speed", tonumber(args.minespeed), " ")
	end
	if g.isGiven(args.minelvl) and tonumber(args.minelvl) then
		out = out .. g.smwProp("Has TiC mining level", tonumber(args.minelvl), " ")
	end
	if g.isGiven(args.dmg) and tonumber(args.dmg) then
		out = out .. g.smwProp("Has TiC attack damage", tonumber(args.dmg)*2, " ")
	end
	if g.isGiven(args.handle) and tonumber(args.handle) then
		out = out .. g.smwProp("Has TiC handle modifier", tonumber(args.handle), " ")
	end
	if g.isGiven(args.smeltery) then
		out = out .. g.smwProp("Uses TiC smeltery", 1, " ")
	else
		out = out .. g.smwProp("Uses TiC smeltery", 0, " ")
	end
	if g.isGiven(args.trait) then
		for trait in string.gmatch(args.trait, "[^;]+") do
			out = out .. g.smwProp("Has TiC trait", trait, " ")
		end
	end
	
	return out
end

return p