遅延実行時のセレクターについて

Last-modified: 2021-10-20 (水) 10:42:51

@aの性質について

まずは「@a」の挙動について説明する。

バニラコマンド以外で@aを実行した場合、@aの部分はプレイヤー名に置き換わり、プレイヤー数だけそのコマンドが実行される。
例えば、サーバー内で「PlayerA」、「PlayerB」、「PlayerC」がいた場合

/jumpboost @a 2

を実行すると、実際には以下のコマンドがそれぞれ一回づつ実行される。(@aがプレイヤー名に置き換わる)

/jumpboost PlayerA 2
/jumpboost PlayerB 2
/jumpboost PlayerC 2

同様に

/sequencecommand 0 tell @a こんにちわ

を実行すると、実際には以下のコマンドがそれぞれ一回づつ実行される。

/sequencecommand 0 tell PlayerA こんにちわ
/sequencecommand 0 tell PlayerB こんにちわ
/sequencecommand 0 tell PlayerC こんにちわ


ここで、もしコマンド内に@aが2つあった場合を考えてみる。
@aは1つづつプレイヤー名に置き換わるという性質がある。
例えば以下のコマンドを実行する。

/sequencecommand 0 tell @a こんにちわ & tell @a ようこそ &

まず1つ目の@aがプレイヤー名に置き換わる。

/sequencecommand 0 tell PlayerA こんにちわ & tell @a ようこそ &
/sequencecommand 0 tell PlayerB こんにちわ & tell @a ようこそ &
/sequencecommand 0 tell PlayerC こんにちわ & tell @a ようこそ &

次に2つ目の@aがプレイヤー名に置き換わり、最終的に以下の9個のコマンドが同時に実行される。

/sequencecommand 0 tell PlayerA こんにちわ & tell PlayerA ようこそ &
/sequencecommand 0 tell PlayerA こんにちわ & tell PlayerB ようこそ &
/sequencecommand 0 tell PlayerA こんにちわ & tell PlayerC ようこそ &
/sequencecommand 0 tell PlayerB こんにちわ & tell PlayerA ようこそ &
/sequencecommand 0 tell PlayerB こんにちわ & tell PlayerB ようこそ &
/sequencecommand 0 tell PlayerB こんにちわ & tell PlayerC ようこそ &
/sequencecommand 0 tell PlayerC こんにちわ & tell PlayerA ようこそ &
/sequencecommand 0 tell PlayerC こんにちわ & tell PlayerB ようこそ &
/sequencecommand 0 tell PlayerC こんにちわ & tell PlayerC ようこそ &

したがってコマンドを1回しか実行していないが、裏では9個のコマンドが実行されてしまう。


@.aについて

「@.a」はTheLowコマンドの内部で「@a」に変換される。@aと違ってコマンド実行前にプレイヤー名に変換されることはない。
つまり、

/sequencecommand 0 tell @.a こんにちわ & tell @.a ようこそ &

を実行するとそのままのコマンドが実行され、「sequencecommand」内部で@.aが@aに変換される。
その後、

tell @a こんにちわ
tell @a ようこそ

が実行される。