m (Fixed things) |
PaladinOne (talk | contribs) (NEW PARAMETER: In , for instability. Takes a number 0-10, produces Instability. IF NIL, assumes Negligible.) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
local infuse = {} |
local infuse = {} |
||
+ | |||
− | --No I don't know [expletive] about Lua, but [expletive] it we'll do it live |
||
+ | local ipairs = ipairs |
||
+ | |||
function rotate(args, f) |
function rotate(args, f) |
||
local function ring(number, offset) |
local function ring(number, offset) |
||
Line 15: | Line 17: | ||
num = 360 / (num-1) |
num = 360 / (num-1) |
||
for i, gc in ipairs(stuff) do |
for i, gc in ipairs(stuff) do |
||
− | page = page .. f:expandTemplate{title="Cg", args={"cell", gc, |
+ | page = page .. f:expandTemplate{title="Cg", args={"cell", gc, 159, 175, style=ring(num, i)}} |
end |
end |
||
end |
end |
||
Line 32: | Line 34: | ||
num = num + 1 |
num = num + 1 |
||
end |
end |
||
− | local start = |
+ | local start = 158 - (num * 17) |
local page = "" |
local page = "" |
||
if #stuff > 0 then |
if #stuff > 0 then |
||
for i, gc in ipairs(stuff) do |
for i, gc in ipairs(stuff) do |
||
− | page = page .. f:expandTemplate{title="Cg", args={"cell", gc, start + line(i), |
+ | page = page .. f:expandTemplate{title="Cg", args={"cell", gc, start + line(i), 317 }} |
end |
end |
||
end |
end |
||
return page |
return page |
||
end |
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) |
infuse.infusion = function(f) |
||
Line 50: | Line 88: | ||
end |
end |
||
− | return "<span>" .. f:expandTemplate{title="Cg", args={nil, 362, |
+ | return "<span>" .. 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) .. "</div></span>" |
end |
end |
||
− | |||
return infuse |
return infuse |
Latest revision as of 23:32, 19 September 2018
Documentation for this module may be created at Module:Infusion/doc
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 "<span>" .. 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) .. "</div></span>"
end
return infuse