理解文件与 JSON
什么是 JSON?
JSON 是保存结构化数据的文本文件。花括号包含具名属性,方括号包含有序列表。字符串使用双引号,数字和 true/false 不加引号。记录之间通过 ID 关联。你可以在文本编辑器中查看文件;通常应在 VNLE 中修改故事后重新导出。
可编辑项目和供游戏使用的导出数据用途不同。请在 VNLE 中修改内容后重新导出。下方片段均来自附带的示例项目。
导出文件夹
story.json Game data: flow + text + catalogs
assets/files/…png Images used by the game
story-index.json Entry points for starting conversations
export-info.json Export result
project/
project.vnle.json Project name, languages, catalog references
chapters/ Chapter structure
flows/ Scene nodes and entry points
layout/ Node positions in the editor
characters/ Characters and portrait references
variables/ Variable definitions and initial values
commands/ Game actions, inputs and outcomes
items/, quests/, locations/ Resources
localization/ Source texts and translations
assets/ Asset catalog and image files教学示例额外提供 guide-map.json,将 ID 与易读名称对应起来。此文件仅属于该示例,并非每个项目都会生成。普通导出中,入口见 story-index.json,内容目录见 story.json。
开始交谈
入口由 flowRef 和 entryRef 组成。两者都是 ID,而非显示名称。解析 execution.entries[entryRef].nodeRef 即可找到执行起点。以下是示例实际使用的 ID:
{
"flowRef": "1f69a7b6-1bdc-4dff-b8ee-9b2819b35168",
"entryRef": "5e6b2e12-1ac1-4c46-8221-1a051e87370a"
}读取对话
{
"continuation": {
"kind": "node",
"nodeRef": "85b3aadf-2b95-4150-bc44-c0c796337874"
},
"flowRef": "1f69a7b6-1bdc-4dff-b8ee-9b2819b35168",
"id": "ffa7141b-97ed-44c1-a346-8bba7e26d94f",
"kind": "dialogue",
"speakerRef": "807b2957-7bab-4a28-83a4-1f3d1589bbc2",
"text": {
"bindings": {},
"textRef": "fd7b61a3-8233-4ba7-8f77-b88b119a91bf"
}
}kind 表示节点类型。speakerRef 指向 content.characters 中的角色,text.textRef 指向 content.texts,continuation 描述点击 Continue 后的行为。
解析文本与语言
{
"id": "fd7b61a3-8233-4ba7-8f77-b88b119a91bf",
"category": "dialogue",
"sourceMessage": {
"kind": "segments",
"segments": [
{
"kind": "text",
"text": "Welcome to the harbour. I am Mira."
}
]
},
"placeholders": {},
"externalUse": false
}若 content.translations[language][text ID].message 存在,则使用该译文,否则使用 sourceMessage。文本片段提供可见文字,占位符片段从节点绑定获取值。语言属于游戏设置,切换语言不会改变进度。
显示姓名与立绘
{
"id": "807b2957-7bab-4a28-83a4-1f3d1589bbc2",
"name": "Mira",
"key": "character_2fbfc3b256cb4ecf94a89965ef8e4549",
"nameTextRef": "ff2cf3d4-08d3-47d8-b41a-86f1a801e1b7",
"color": "#82d5e6",
"defaultPortraitRef": "eacb484c-0663-4ffd-876d-401664b980db",
"emotions": {}
}像其他文本一样解析 nameTextRef。图片使用所选表情对应的立绘,或 defaultPortraitRef。通过 content.assets[portrait ID].relativePath 查找文件,并将 assets 与 story.json 一起复制到游戏中。