-
Notifications
You must be signed in to change notification settings - Fork 0
Action Node
Noogear edited this page Mar 9, 2026
·
1 revision
action 节点用于调用已注册的动作函数。
# 标准格式
- action: "showIndicator"
args: ["{target}", "{source}", "{value}", "CRITICAL"]
# 捕获返回值
- action: "someAction"
args: ["arg1"]
store: "result"| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
action |
String | 是 | 已注册的动作名 |
args |
List | 否 | 参数列表,支持 {变量} 模板插值 |
store |
String | 否 | 将返回值存入此变量名 |
当节点不包含任何保留键(check、switch、return、any、all、math、collect、action、type)时,引擎将第一个字段视为动作名,其值视为参数列表。
# 以下两种写法等价
- action: "sendMessage"
args: ["hello"]
- sendMessage: ["hello"]短语法使 YAML 更简洁:
flow:
- showIndicator: ["{target}", "{source}", "{value}", "CRITICAL"]
- sendMessage: ["你好,{playerName}"]
- playSound: ["ENTITY_EXPERIENCE_ORB_PICKUP"]- action: "showIndicator"
args: ["{target}", "{source}", "{damage}", "{cause.name}"]- action: "calculateBonus"
args: ["{level}", "{weapon}"]
store: "bonus"
# 后续节点可使用 bonus 变量
- action: "applyDamage"
args: ["{bonus}"]flow:
- playSound: ["ENTITY_PLAYER_HURT"]
- sendMessage: ["你受到了 {damage} 点伤害"]
- spawnParticle: ["{target}", "DAMAGE_INDICATOR"]