特质注册

Estimated reading time: less than 1 minute

通过 maplebirch.tool.patch.addTraits() 注册自定义特质。

请使用 maplebirch.tool.patch.addTraits()

特质接口

字段类型说明
titlestring特质标题 / 分类
namestring特质标识名(必须)
colourstring显示颜色
hasFunction | string拥有条件(函数或表达式字符串)
textstring特质描述文本

示例

const other = maplebirch.tool.patch;

other.addTraits({
  title: "一般特质",
  name: "brave",
  colour: "green",
  has: () => V.brave >= 1,
  text: "角色展现出勇气",
});

other.applyLocation();

说明

框架对特质添加做了内部解析与去重,避免重复或错误覆盖。maplebirch.tool.patch.addTraits 的用法保持不变。

boot.json

也可以通过 boot.jsonframework 字段注册特质:

{
  "framework": {
    "traits": [
      {
        "title": "General Traits",
        "name": "brave",
        "colour": "green",
        "has": "V.brave >= 1",
        "text": "Character shows courage"
      }
    ]
  }
}

也可以引用 .json.yaml.yml 文件:

{
  "framework": {
    "traits": "data/traits.yaml"
  }
}