跳到主要内容
版本:4.x

非 Excel 数据源

表的 input 不只可以是 xlsx,还可以是 json / xml / yaml / lua / 目录等。技能、AI、编辑器导出的结构化数据常用这类源。

input 写法

形式含义示例
foo.xlsxExcelitem.xlsx
sheet@foo.xlsx指定 sheetBag@ui.xlsx
a.xlsx,b.xlsx多文件合并
foo.json单条记录单例或一条配置
*@foo.json记录列表表数据主文件
field@foo.json从某字段取单条data@bundle.json,支持 a.b.c
*field@foo.json从某字段取列表*items@bundle.json
目录遍历文件忽略以 . ~ _ 开头的名字
<table name="TbItem" value="Item" index="id" input="item.xlsx"/>
<table name="TbSkill" value="Skill" index="id" input="*@skill/skills.json"/>
<table name="TbGlobal" value="Global" mode="one" input="global.json"/>

JSON 列表示例(*@items.json

[
{ "id": 1, "name": "剑", "cost": { "id": 1001, "count": 2 } },
{ "id": 2, "name": "盾", "cost": { "id": 1002, "count": 1 } }
]

多态字段:

{
"id": 1,
"shape": { "$type": "Circle", "radius": 1.5 }
}

map:默认常为 [[k,v],[k,v]] 形式(与 dataTarget json 一致);以当前版本解析为准。

JSON 单记录(global.json

{
"bag_init_size": 20,
"bag_max_size": 100,
"guild_open_level": 10
}

__tables__mode=oneinput=global.json

Lua(文件需 return

return {
{ id = 1, name = "剑", shape = { _type_ = "Circle", radius = 1.5 } },
{ id = 2, name = "盾", shape = { _type_ = "Rect", width = 2, height = 3 } },
}

列表文件配合 *@xxx.lua;注意多态键是 _type_

XML

<record>
<id>1</id>
<name></name>
<shape type="Circle">
<radius>1.5</radius>
</shape>
</record>

集合常用重复 <item> 节点;map 用 key/value 子节点(详见示例工程)。

YAML

与 JSON 类似,多态仍用 $type

- id: 1
name:
shape:
$type: Circle
radius: 1.5

目录数据源

input="skills"skills/ 下有多个文件时:

文件类型默认语义
非 Excel每个文件一条记录(文件名常可当辅助;以解析规则为准)
Excel仍按多记录表处理

需要「一个 json 里很多行」时,用 *@file.json,不要只写目录却期望自动当数组。

复合 input 组合

item.xlsx,*@item_extra.json

Excel 与 JSON 列表可拼到同一张逻辑表(注意主键别冲突)。

格式对照(单记录内)

json/yamlluaxml
多态类型$type_type_属性 type
map[[k,v],...]{[k]=v,...}key/value item
set数组item 节点

另有 .lit(lite 文件),语义接近单元格 lite

常见坑

  • 写了 skills.json(单记录)却放了数组 → 应改成 *@skills.json
  • JSON 用了 _type_、Lua 用了 $type → 键名与格式不匹配。
  • 目录里文件名以 _ 开头被忽略。
  • 与 Excel 混用时主键重复导致校验失败。

相关链接