メインコンテンツまでスキップ

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

スコアを使用したコマンド

スコアに基づいてコマンドを実行します。

/execute as @a run scriptevent capi:run give @s diamond <!score=reward_count>

条件付きコマンド実行

条件に応じてコマンドを実行します。

/execute as @a run scriptevent capi:run <!if=<!score=health><10>effect @s regeneration 10 1<!endif>

複雑なコマンドの実行

複数のマクロを組み合わせたコマンドを実行します。

/scriptevent capi:run tp @s <!calc=floor({x})> <!calc=floor({y})+10> <!calc=floor({z})>

タグに基づくコマンド

タグを使用したコマンドを実行します。

/execute as @a run scriptevent capi:run effect @s <!tag=effect> 30 1

注意事項

  • エンティティのみが実行できます
  • コマンドにはスラッシュ(/)を付けないでください
  • マクロはコマンド実行前に展開されます
  • エラーが発生した場合、詳細なエラーメッセージが表示されます

関連項目

  • call - 登録されたコマンドセットを呼び出し