モジュール:Grid/Crafting Square Numbers

提供:Azipedia
ナビゲーションに移動 検索に移動

このモジュールについての説明文ページを モジュール:Grid/Crafting Square Numbers/doc に作成できます

local p = {}

local g = require("Module:FTBCommon")
local s = require("Module:FTBSprite")

function p.makeCraftingNumbers(amount, link)
	local pos = {11, 11, 11}
	
	if amount > 1 then
		if amount > 99 then
			pos[1] = math.floor(amount / 100)
			amount = math.mod(amount, 100)
			pos[2] = math.floor(amount / 10)
			amount = math.mod(amount, 10)
		elseif amount > 9 then
			pos[2] = math.floor(amount / 10)
			amount = math.mod(amount, 10)
		end
		pos[3] = amount
	elseif amount == 0 then
		pos[3] = 0
	end
	
	-- Value for 0 is at position 10 in the sprite sheet
	for idx = 1, 3, 1 do
		if pos[idx] == 0 then
			pos[idx] = 10
		end
	end
	
	local output = "<span>" .. s.makeSprite("GridNumbersCSS.png", pos[1] - 1, 16, 64, link) .. "</span>"
	output = output .. "<span style=\"position:absolute; left:12px;\">" .. s.makeSprite("GridNumbersCSS.png", pos[2] - 1, 16, 64, link) .. "</span>"
	output = output .. "<span style=\"position:absolute; left:24px;\">" .. s.makeSprite("GridNumbersCSS.png", pos[3] - 1, 16, 64, link) .. "</span>"

	return output
end

function p.main(frame)
	return p.makeCraftingNumbers(tonumber(frame.args[1] or 1), frame.args[2] or '')
end

return p