モジュール:Astrology

提供: 萌えっ娘百科事典
2019年7月3日 (水) 17:27時点におけるHuanying04 (トーク | 投稿記録)による版 (ページの作成:「local p = {} local getArgs = require('Module:Arguments').getArgs function p._convert(args) local month = tonumber(args[1]) local day = tonumber(args[2]) if month ==…」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

星座計算。

使い方

{{#invoke:Astrology|convert|月|日}}
例えば:
{{#invoke:Astrology|convert|1|30}}→みずがめ座


local p = {}

local getArgs = require('Module:Arguments').getArgs

function p._convert(args)
	local month = tonumber(args[1])
	local day = tonumber(args[2])
	if month == nil or day == nil then
		error('媒介変数Error')
	end
	local combined = string.format('%02d%02d', month, day)
	if combined < '0121' then
		return 'やぎ座'
	elseif combined < '0220' then
		return 'みずがめ座'
	elseif combined < '0321' then
		return 'うお座'
	elseif combined < '0421' then
		return 'おひつじ座'
	elseif combined < '0522' then
		return 'おうし座'
	elseif combined < '0622' then
		return 'ふたご座'
	elseif combined < '0723' then
		return 'かに座'
	elseif combined < '0823' then
		return 'しし座'
	elseif combined < '0923' then
		return 'おとめ座'
	elseif combined < '1024' then
		return 'てんびん座'
	elseif combined < '1123' then
		return 'さそり座'
	elseif combined < '1222' then
		return 'いて座'
	else
		return 'やぎ座'
	end

end

function p.convert(frame)
	local args = getArgs(frame, {wrappers='Template:Astrology'})
	return p._convert(args)
end

return p