Module:Grid/Alloying

From ATLauncher Wiki
Jump to: navigation, search
Lua Logo.svg This is the Lua module for Template:Grid/Alloying. Below is the documentation for that template.

This template is used to create Smeltery Alloying recipes for Tinkers' Construct.

Syntax[edit]

Type {{Grid/Alloying|<param>}} somewhere.

Parameters[edit]

  • Inputs: Number of input fluids.
  • Fluid[1-x]: Input fluids.
  • Fluid[1-x]-amount: Input fluid amounts, in millibuckets.
  • Output: Output fluid.
  • Output-amount: Output fluid amounts, in millibuckets.

Examples[edit]

{{Grid/Alloying
|Inputs=3
|Fluid1=Molten Silver (Tinkers' Construct) |Fluid1-amount=144
|Fluid2=Molten Copper (Tinkers' Construct) |Fluid2-amount=432
|Fluid3=Destabilized Redstone |Fluid3-amount=1000
|Output=Molten Signalum (Tinkers' Construct) |Output-amount=576
}}

gives...

GUI Alloying.png
Smeltery Alloying

SmelteryInvisible-2.png


SmelteryInvisible-3.png


SmelteryInvisible-3.png


SmelteryInvisible-3.png

}}



local p = {}
local g = require("Module:Common")
local frame2
local mul

local function gauge(left, width, fluid, amount, num)
	return frame2:expandTemplate{title = "FluidGauge", args = {left = left, width = width,
		Fluid = fluid, Amount = amount/mul / 1000, height = 78, Multiplier = mul, top = 40,
		img = num <= 6 and "SmelteryInvisible-" .. num .. ".png" or "TranspLine.png",
		Size = width .. "x78px"}}
end

function p.main(frame)
	local args
	frame2, args = g.getFrameAndArgs(frame)
	local num = tonumber(args.Inputs)
	
	local maxH = tonumber(args["Output-amount"])
	for i = 1, num do
		local k = tonumber(args["Fluid" .. i .. "-amount"])
		if maxH < k then maxH = k end
	end
	mul = 120/78 * maxH / 10000
	
	local S = '<div style="left:10px; top:13px; width:332px; text-align:center;' ..
		'position:absolute; color:#404040; font-size:16px; font-family: Minecraftia;">' ..
		'Smeltery Alloying</div>' ..
		gauge(252, 36, args.Output, args["Output-amount"], 2)
	
	local shift = 72 / num
	for i = 1, num do
		S = S .. gauge(58 + (i-1) * shift, shift, args["Fluid" .. i], args["Fluid" .. i .. "-amount"], num)
	end
	
	S = S .. "}}"
	S = frame2:expandTemplate{title = "Grid", args = {content = S, nobreak = args.nobreak or "",
		float = args.float or "", width = 352, height = 161, link = "Smeltery", bg = "GUI Alloying.png"}}
	return S
end

return p