run
概要
run は、コマンドを実行する ScriptEvent です。
マクロを展開してからコマンドを実行できます。
構文
/scriptevent capi:run <コマンド>
パラメータ
| パラメータ | 説明 |
|---|---|
コマンド | 実行するコマンド(スラッシュなし) |
使用例
シンプルなコマンド実行
コマンドを実行します。
/execute as @a run scriptevent capi:run say Hello!
プレイヤー名を含むコマンド
マクロを使用してプレイヤー名を含むコマンドを実行します。
/execute as @a run scriptevent capi:run say <!name> joined the game
実行結果:
Notch joined the game
Name マクロ
../Macro/Name
スコアを使用したコマンド
スコアに基づいてコマンドを実行します。
/execute as @a run scriptevent capi:run give @s diamond <!score=reward_count>
Score マクロ
../Macro/Score
条件付きコマンド実行
条件に応じてコマンドを実行します。
/execute as @a run scriptevent capi:run <!if=<!score=health><10>effect @s regeneration 10 1<!endif>
If マクロ
../Macro/If
複雑なコマンドの実行
複数のマクロを組み合わせたコマンドを実行します。
/scriptevent capi:run tp @s <!calc=floor({x})> <!calc=floor({y})+10> <!calc=floor({z})>
Calc マクロ
../Macro/Calc
タグに基づくコマンド
タグを使用したコマンドを実行します。
/execute as @a run scriptevent capi:run effect @s <!tag=effect> 30 1
Tag マクロ
../Macro/Tag
注意事項
- エンティティのみが実行できます
- コマンドにはスラッシュ(/)を付けないでください
- マクロはコマンド実行前に展開されます
- エラーが発生した場合、詳細なエラーメッセージが表示されます
関連項目
- call - 登録されたコマンドセットを呼び出し