Module:新港地铁数据
让世界变得更有趣吧!
更多操作
概述
本模块用于存储和检索新港地铁系统的线路基础数据(颜色、简写、图标等)。它主要供其他模板(如线路标志、车站信息框)调用。
函数用法
color
获取线路的十六进制颜色代码。
- 用法:
000000 - 参数:
1(线路名称):如“新港线”。2(可选):输入s则返回带#前缀的颜色(如 #B02446),否则仅返回 6 位代码。
short
获取线路的两位字母代码。
- 用法:
线路名称 - 返回:如 EA, EB 等。如果线路不存在,则返回输入的原名。
textcolor
获取在线路颜色背景上建议使用的文字颜色(用于保证对比度)。
- 用法:
white - 返回:通常为
white。
icon
获取线路图标的文件名。
- 用法:
新港地铁标志_线路名称.svg - 返回:模块定义的
.svg文件名。若未定义,则按新港地铁数据_代码.svg规则生成。
---
已定义线路数据
| 线路名称 | 颜色代码 | 示例 | 简写 | 图标文件名 | 文字颜色 |
|---|---|---|---|---|---|
| 新港线 | B02446 |
SK | SK | white | |
| 新北线 | 7D499D |
SH | SH | white |
默认处理
当输入的线路名称未在数据库中定义时:
- 颜色:默认为
000000(黑色)。 - 代码:返回输入值本身。
- 图标:尝试匹配
新港地铁标志_代码.svg。
local p = {}
-- ============================================================
-- 配置区域:请只修改以下内容
-- color: 颜色代码 (不带#)
-- short: 线路两位英文代码
-- icon: 图标文件名
-- textcolor: 徽章内的文字颜色
-- ============================================================
local lines = {
['新港线'] = { color = 'B02446', short = 'SK', icon = 'SK_icon.svg', textcolor = 'white' },
['新北线'] = { color = '7D499D', short = 'SH', icon = 'SH_icon.svg', textcolor = 'white' },
}
-- ============================================================
-- 配置区域结束
-- ============================================================
local function get_line_data(name)
return lines[name] or { color = '000000', short = name, textcolor = 'white' }
end
function p.color(frame)
local line = frame.args[1] or ""
local mode = frame.args[2] or ""
local data = get_line_data(line)
return (mode == 's' and '#' or '') .. data.color
end
function p.short(frame)
local line = frame.args[1] or ""
local data = lines[line]
if data and data.short then
return data.short
end
return line
end
function p.textcolor(frame)
local line = frame.args[1] or ""
local data = get_line_data(line)
return data.textcolor or 'white'
end
function p.icon(frame)
local line = frame.args[1] or ""
local data = get_line_data(line)
if data.icon then
return data.icon
end
return '新港地铁标志_' .. (data.short or line) .. '.svg'
end
return p