Module:Infusion

local infuse = {}

local ipairs = ipairs

function rotate(args, f)	local function ring(number, offset) return "transform: rotate(" .. ((number or 0) * (offset or 0)) .. "deg) translate(80px) rotate(" .. ((-number or 0) * (offset or 0)) .. "deg);" end local num = 1 local stuff = {} while args["I" .. num] ~= nil do table.insert(stuff, args["I" .. num]) num = num + 1 end local page = "" if #stuff > 0 then num = 360 / (num-1) for i, gc in ipairs(stuff) do page = page .. f:expandTemplate{title="Cg", args={"cell", gc, 159, 175, style=ring(num, i)}} end end return page end

function space(args, f)	local function line (number) return ((number or 0) * 34) end local num = 1 local stuff = {} while args["A" .. num] ~= nil do table.insert(stuff, args["A" .. num]) num = num + 1 end local start = 158 - (num * 17) local page = "" if #stuff > 0 then for i, gc in ipairs(stuff) do page = page .. f:expandTemplate{title="Cg", args={"cell", gc, start + line(i), 317 }} end end return page end

function instability(args, f)	local num = 0 if ( not (args["In"] == nil)) then num = math.floor( args["In"] / 2) end if(num < 0) then num = 0 elseif (num > 5) then num = 5 end local values = { [0] = "Negligible", [1] = "Minor", [2] = "Moderate", [3] = "High", [4] = "Very High", [5] = "Dangerous", }	local colors = { [0] = "00A", [1] = "5FF", [2] = "A0A", [3] = "FF5", [4] = "FA0", [5] = "A00", }	local instab = values[num] local clr = colors[num] local page=	f:expandTemplate{title="Cg", args={"text", nil, "Instability: " .. f:expandTemplate{title="Color", args={clr, instab}}, nil, 76, 292, class="craftingGridText" }} return page end

infuse.infusion = function(f) local args = f.args or f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end return " " .. f:expandTemplate{title="Cg", args={nil, 362, 360}} .. f:expandTemplate{title="Cg", args={"bg-image", "GUI Arcane Infusion.png"}} .. f:expandTemplate{title="Cg", args={"text", require("Module:Language").link({"Infusion Altar", --"Infusion Altar"--}), nil, nil, 0, 4, class="craftingGridText craftingGridLink craftingGridTitle"}} .. rotate(args, f) .. f:expandTemplate{title="Cg", args={"cell", args.C or "", 159, 175}} .. f:expandTemplate{title="Cg", args={"cell", args.O or "", 157, 39}} .. space(args, f) .. instability(args,f) .. " "  end return infuse