打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Module:雅各宾数据

让世界变得更有趣吧!

概述

本模块用于存储和检索雅各宾系统的线路基础数据(颜色、简写、图标等)。它主要供其他模板(如线路标志、车站信息框)调用。

函数用法

color

获取线路的十六进制颜色代码。

  • 用法000000
  • 参数
    • 1 (线路名称):如“纵深城际”。
    • 2 (可选):输入 s 则返回带 # 前缀的颜色(如 #20000),否则仅返回 6 位代码。

short

获取线路的两位字母代码。

  • 用法线路名称
  • 返回:如 EA, EB 等。如果线路不存在,则返回输入的原名。

textcolor

获取在线路颜色背景上建议使用的文字颜色(用于保证对比度)。

  • 用法white
  • 返回:通常为 white

icon

获取线路图标的文件名。

  • 用法雅各宾标志_线路名称.svg
  • 返回:模块定义的 .svg 文件名。若未定义,则按 雅各宾数据_代码.svg 规则生成。

---

已定义线路数据

线路名称 颜色代码 示例 简写 图标文件名 文字颜色
纵深城际 A20000 S1 S1 S1_icon.svg white

默认处理

当输入的线路名称未在数据库中定义时:

  • 颜色:默认为 000000 (黑色)。
  • 代码:返回输入值本身。
  • 图标:尝试匹配 雅各宾标志_代码.svg

local p = {}

-- ============================================================
-- 配置区域:请只修改以下内容
-- color: 颜色代码 (不带#)
-- short: 线路两位英文代码
-- icon: 图标文件名
-- textcolor: 徽章内的文字颜色
-- ============================================================
local lines = {
    ['纵深城际'] = { color = 'A20000', short = 'S1', icon = 'S1_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