コンテンツにスキップ
大乱闘スマッシュブラザーズWikiで記事を編集するにはアカウントの作成ログインが必要です。編集方法や方針などについては、大乱闘スマッシュブラザーズWiki:編集ガイドライン‎をご覧ください。

「モジュール:有無」の版間の差分

提供: 大乱闘スマッシュブラザーズWiki
編集の要約なし
何故テストではいけて本番ではエラーが出るのか
16行目: 16行目:
end
end


local function templateDivided(colors, textLeft, textRight)
local function templateDivided(ccc, textLeft, textRight)
local str = [[
local str = [[
<span style="white-space:nowrap;">
<span style="white-space:nowrap;">
58行目: 58行目:
</span>  
</span>  
]]
]]
local colors
if ccc == nil then
    color = COLORS_FOR_01
else
colors = ccc
end


str = replaceAll(str, "★fontColorLeft★", colors.FONT_LEFT)
str = replaceAll(str, "★fontColorLeft★", colors.FONT_LEFT)

2026年3月8日 (日) 20:06時点における版

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

local p = {}

local function outputobj(tbl)
	local result = {}

	for k, v in pairs(tbl) do
		table.insert(result, tostring(k) .. "=" .. tostring(v))
	end

	return table.concat(result, ", ")
end

local function replaceAll(a, b, c)
	local result = string.gsub(a, b, c)
	return result
end

local function templateDivided(ccc, textLeft, textRight)
	local str = [[
		<span style="white-space:nowrap;">
			<span
				style="
					display:inline-block;
					bottom:1px;
					position:relative;
					line-height:1.5em;
					text-align:center;
					font-size:70%;
					font-weight:bold;
					width:1.75em;
					border:solid 1px ★borderColorLeft★;
					border-radius:1em 0 0 1em;
					background:★bgColorLeft★;
					color:★fontColorLeft★;
				"
			>
			★textLeft★
			</span>
			<span
				style="
					display:inline-block;
					bottom:1px;
					position:relative;
					line-height:1.5em;
					text-align:center;
					font-size:70%;
					font-weight:bold;
					width:1.75em;
					border:solid 1px ★borderColorRight★;
					border-radius:0 1em 1em 0;
					margin-right:3px;
					background:★bgColorRight★;
					color:★fontColorRight★;
				"
			>
			★textRight★
			</span> 
		</span> 
	]]
		
	local colors
if ccc == nil then
    color = COLORS_FOR_01
else
		colors = ccc
end

	str = replaceAll(str, "★fontColorLeft★", colors.FONT_LEFT)
	str = replaceAll(str, "★bgColorLeft★", colors.BG_LEFT)
	str = replaceAll(str, "★borderColorLeft★", colors.BORDER_LEFT)
	str = replaceAll(str, "★textLeft★", textLeft)
	str = replaceAll(str, "★fontColorRight★", colors.FONT_RIGHT)
	str = replaceAll(str, "★bgColorRight★", colors.BG_RIGHT)
	str = replaceAll(str, "★borderColorRight★", colors.BORDER_RIGHT)
	str = replaceAll(str, "★textRight★", textRight)
	return str
end

local function templateOne(colors, text)
	local str = [[
		<span style="white-space:nowrap;">
			<span
				style="
					display:inline-block;
					bottom:1px;
					position:relative;
					line-height:1.5em;
					text-align:center;
					font-size:70%;
					font-weight:bold;
					width:3.5em;
					border:solid 1px ★borderColor★;
					border-radius:1em;
					margin-right:3px;
					background:★bgColor★;
					color:★fontColor★;
				"
			>
			★text★
			</span>
		</span> 
	]]
	str = replaceAll(str, "★fontColor★", colors.FONT)
	str = replaceAll(str, "★bgColor★", colors.BG)
	str = replaceAll(str, "★borderColor★", colors.BORDER)
	str = replaceAll(str, "★text★", text)
	return str
end

local BG_COLORS = {
	OFF="#FFF",
	N64="rgb(151,114,19)",
	DX="#705DA8",
	X="#FE6061",
	FOR3DS='#9A1424',
	FORWIIU='#0096C8',
	SP='repeating-linear-gradient(-45deg, #4d4d4d, #4d4d4d 1px, #000 1px, #000 4px)',
	UNKNOWN='#008000'
}

local FONT_COLORS = {
	OFF="#808080",
	ON="#FFF"
}

local BORDER_COLORS = {
	ON="transparent",
	OFF="#ccc"
}

local COLORS_OFF = {
	BG=BG_COLORS.OFF,
	FONT=FONT_COLORS.OFF,
	BORDER=BORDER_COLORS.OFF
}
local COLORS_UNKNOWN = {
	BG=BG_COLORS.UNKNOWN,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}
local COLORS_64 = {
	BG=BG_COLORS.N64,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}
local COLORS_DX = {
	BG=BG_COLORS.DX,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}
local COLORS_X = {
	BG=BG_COLORS.X,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}
local COLORS_3DS = {
	BG=BG_COLORS.FOR3DS,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}
local COLORS_WIIU = {
	BG=BG_COLORS.FORWIIU,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}
local COLORS_FOR_00 = {
	BG_LEFT=BG_COLORS.OFF,
	FONT_LEFT=FONT_COLORS.OFF,
	BORDER_LEFT=BORDER_COLORS.OFF,
	BG_RIGHT=BG_COLORS.OFF,
	FONT_RIGHT=FONT_COLORS.OFF,
	BORDER_RIGHT=BORDER_COLORS.OFF
}
local COLORS_FOR_01 = {
	BG_LEFT=BG_COLORS.OFF,
	FONT_LEFT=FONT_COLORS.OFF,
	BORDER_LEFT=BORDER_COLORS.OFF,
	BG_RIGHT=BG_COLORS.FORWIIU,
	FONT_RIGHT=FONT_COLORS.ON,
	BORDER_RIGHT=BG_COLORS.FORWIIU
}
local COLORS_FOR_10 = {
	BG_LEFT=BG_COLORS.FOR3DS,
	FONT_LEFT=FONT_COLORS.ON,
	BORDER_LEFT=BORDER_COLORS.FOR3DS,
	BG_RIGHT=BG_COLORS.OFF,
	FONT_RIGHT=FONT_COLORS.OFF,
	BORDER_RIGHT=BG_COLORS.OFF
}
local COLORS_FOR_11 = {
	BG_LEFT=BG_COLORS.FOR3DS,
	FONT_LEFT=FONT_COLORS.ON,
	BORDER_LEFT=BORDER_COLORS.FOR3DS,
	BG_RIGHT=BG_COLORS.FORWIIU,
	FONT_RIGHT=FONT_COLORS.ON,
	BORDER_RIGHT=BG_COLORS.FORWIIU
}
local COLORS_SP = {
	BG=BG_COLORS.SP,
	FONT=FONT_COLORS.ON,
	BORDER=BORDER_COLORS.ON
}

local TITLES = {
	N64='64',
	DX='DX',
	X='X',
	FOR3DS='3DS',
	FORWIIU='WiiU',
	FOR='for',
	SP='SP'
}


function getTemplateDividedFor(on)
	if on == '0/0' then
		return templateDivided(COLORS_FOR_00, '3', 'U')
	elseif on == '0/1' then
		return templateDivided(COLORS_FOR_01, '3', 'U')
	elseif on == '1/0' then
		return templateDivided(COLORS_FOR_10, '3', 'U')
	elseif on == '1/1' then
		return templateDivided(COLORS_FOR_11, '3', 'U')
	else 
		return templateDivided(COLORS_FOR_00, '3', 'U')
	end
end

function getTemplateOneOn(title)
	if title == TITLES.N64 then
		return templateOne(COLORS_64, TITLES.N64)
	elseif title == TITLES.DX then
		return templateOne(COLORS_DX, TITLES.DX)
	elseif title == TITLES.X then
		return templateOne(COLORS_X, TITLES.X)
	elseif title == TITLES.FOR3DS then
		return templateOne(COLORS_3DS, TITLES.FOR3DS)
	elseif title == TITLES.FORWIIU then
		return templateOne(COLORS_WIIU, TITLES.FORWIIU)
	elseif title == TITLES.SP then
		return templateOne(COLORS_SP, TITLES.SP)
	else
		return templateOne(COLORS_UNKNOWN, '?')
	end
end

function getTemplateOneOff(title)
	local t = ''
	if title == TITLES.N64 then
		t = TITLES.N64
	elseif title == TITLES.DX then
		t = TITLES.DX
	elseif title == TITLES.X then
		t = TITLES.X
	elseif title == TITLES.FOR3DS then
		t = TITLES.FOR3DS
	elseif title == TITLES.FORWIIU then
		t = TITLES.FORWIIU
	elseif title == TITLES.SP then
		t = TITLES.SP
	else
		t = '?'
	end

	return templateOne(COLORS_OFF, t)
end
--[[
	frame.args.title	64|DX|X|3DS|WiiU|for|SP
	frame.args.on		0|1|0/0|0/1|1/0|1/1
]]--
function p.main(frame)
	local a = frame.args
	
	if a.title == TITLES.FOR then
		return getTemplateDividedFor(a.on)
	end
	
	if a.on == '0' then
		return getTemplateOneOff(a.title)
	end
	return getTemplateOneOn(a.title)
end

return p