/scoreboard - スコアボードを操作する

/scoreboard - スコアボードを操作する

各エンティティに独自の数字を持たせ、管理するコマンドです。

  • objectivesは、各エンティティがどのような入れ物を持つのかを操作します。
  • playersは、そのエンティティが持っている入れ物に、何を・どう入れるのかを操作します。
  • 箱の中に入れられるのは数字(整数)だけです(-21億から+21億の間)。文字は入りません。
  • 箱の中に何も入っていない場合はundefined(未定義)になります。0ではありません。

objectives - 全体のオブジェクトの枠組みを操作する

objective は日本語に訳すのが難しいので、そのまま「オブジェクト」とします。 数字を入れておく箱のようなものだと思ってください。

/socreboard objectives
add
オブジェクトを作成する
<objective>
オブジェクト名
dummy
[displayName]
表示名
remove
オブジェクトを削除する
list
オブジェクトの一覧を見る
setdisplay
オブジェクトの値を表示
list
ポーズ画面
[objective]
オブジェクト名
[ascending|descending]
並び順
sidebar
画面右側
belowname
名前の下

オブジェクトを追加する

/scoreboard objectives add <オブジェクト名> dummy [表示名]

# オブジェクト「score」を追加、表示名は「スコア」
/scoreboard objectives add score dummy スコア

オブジェクトを削除する

/scoreboard objectives remove <オブジェクト名>

# オブジェクト「score」を削除
/scoreboard objectives remove score

オブジェクトの一覧を表示する

/scoreboard objectives list

# 現在登録されているオブジェクトの一覧を表示
/scoreboard objectives list

オブジェクトを画面に表示する

/scoreboard objectives setdisplay <list|sidebar> [オブジェクト名] [並び順]]

# オブジェクト「score」をlistに降順(大きい数から)で表示
/scoreboard objectives setdisplay list score descending

# オブジェクト「score」をsidebaに昇順(小さい数から)で表示
/scoreboard objectives setdisplay sidebar score ascending

オブジェクトを名前の下に表示する

/scoreboard objectives setdisplay belowname [オブジェクト名]

# オブジェクト「score」を各エンティティの名前の下に表示
/scoreboard objectives setdisplay belowname score

players - 個別のオブジェクトの値を操作する

名称はプレイヤーとなっていますが、すべてのエンティティが対象です。 例えば、「防具立て」や「トロッコ」にもオブジェクトを持たせることができます。

/scoreboard players
list
そのエンティティの持つオブジェクト名一覧を見る
[playername]
対象者
reset
オブジェクトの値を初期化する
(x = undefined)
<player>
対象者
[objective]
オブジェクト名
test
オブジェクトを値を評価する
(if(min <= x && x <= max))
コマンドブロックで実行した際に、真ならコンパレーターを通して信号が出力される。
<objective>
オブジェクト名
<min> [max]
範囲(ワイルドカードあり)
random
オブジェクトに無作為な値を代入する
(x = Math.random(min, max))
<min> [max]
範囲
set
オブジェクトを指定の値にする
(x = count)
<count>
数字
add
オブジェクトに指定の値を加える
(x += count)
remove
オブジェクトを指定の値で減らす
(x -= count)

オブジェクト名を表示する

/scoreboard players list [誰の]

そのエンティティが持っているオブジェクトの一覧を表示する。

/scoreboard players list @s

オブジェクトを初期化する

/scoreboard players reset <誰の> [オブジェクト名]

# 「score」オブジェクトの値を初期化する
/scoreboard players reset @s score

# オブジェクト名を指定しないとすべてのオブジェクトが初期化される
/scoreboard players reset @s

オブジェクトの値が特定の範囲内にあるかどうかを検査する

/scoreboard players test <誰の> <オブジェクト名> <最小値> [最大値]

# オブジェクトの値が1以上100以下かどうか
/scoreboard players test @s score 1 100
# オブジェクトの値が100ちょうどかどうか
/scoreboard players test @s score 100 100

# オブジェクトの値が50以下かどうか
/scoreboard players test @s score * 50
# オブジェクトの値が50以上かどうか
/scoreboard players test @s score 50 *
# 最大値の方は指定しない場合と同じ
/scoreboard players test @s score 50

# オブジェクトの値になにかの数字が入っているか
# undefinedではないことを調べられる
/scoreboard players test @s score * *
# これと同じ意味
/scoreboard players test @s score -2147483648 2147483647

これ自体は何も影響を与えません。 testfortestforblockなどと同じように、判定に使用します。 判定が成功したら、成功判定としてコンパレーターから信号を出します、またコマンドブロックの条件も有効になります。

オブジェクトにランダムな値を入れる

/scoreboard players random <誰の> <オブジェクト名> <最小値> <最大値>

# 1から100までの数字をランダムに入れる
/scoreboard players random @s score 1 100

オブジェクトに指定した値をそのまま入れる

setを使うと、そのオブジェクトの値を指定した数にします。 元の値に関係なく、その数で上書きしてしまいます。

/scoreboard players set <誰の> <オブジェクト名> <整数>

/scoreboard players set @s score 50

オブジェクトを指定した値で増やす

addを使うと、そのオブジェクトの値を増やすことができます。 元の値がundefinedであった場合は0として扱われ、0から足した数になります。

/scoreboard players add <誰の> <オブジェクト名> <整数>

/scoreboard players add @s score 50

オブジェクトを指定した値で減らす

/scoreboard players remove <誰の> <オブジェクト名> <整数>

元の値がundefinedであった場合は0として扱われ、0から引いた数になります。

/scoreboard players remove @s score 50

players operation - オブジェクト同士を計算する

演算子(+や-などの記号)を使って、オブジェクト同士を計算できます。

/scoreboard players operation <変更される方> <オブジェクト名> <演算子> <計算に使う方> <オブジェクト名>

/scoreboard players operation @a[tag=achieved] score += @e[tag=admin] reward

長いので次のまとまりをx,yと表します。

  • x: <変更される方> <オブジェクト名>
  • y: <計算に使う方> <オブジェクト名>
/scoreboard players
operation
オブジェクト同士で計算
x
変更される方
+=
足す(加算)(x = x + y)
y
計算に使う方
-=
引く(減算)(x = x - y)
*=
掛ける(乗算)(x = x * y)
/=
割る(除算。余りは切り捨て)
(x = Math.floor(x / y))
%=
余り(剰余): 割った後の余りを入れる
(x = x % y)
=
代入: 同じ値を入れる(x = y)
<
小さい方: 2つのうち小さい方を入れる
(x = Math.min(x, y))
>
大きい方: 2つのうち大きい方を入れる
(x = Math.max(x, y))
><
入れ替え: 値を入れ替える
([x, y] = [y, x])

計算に使う方のオブジェクトがundefinedだとエラーです。

例文のための準備

# 防具立てを「Global」という名前で呼び出す
/summon armor_stand Global

# 全員にscoreオブジェクトを作成
/scoreboard objectives add score
# Globalのscoreを30にする
/scoreboard players set Global score 30
# scoreを名前の下に表示
/scoreboard objectives setdisplay sidebar score

別のオブジェクトの値で足す

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)を、Globalのscore(30)で足す(100 + 30)
/scoreboard players operation @s score += Global score
# -> 130

別のオブジェクトの値で引く

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)を、Globalのscore(30)で引く(100 - 30)
/scoreboard players operation @s score -= Global score
# -> 70

別のオブジェクトの値で掛ける

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)を、Globalのscore(30)で掛ける(100 * 30)
/scoreboard players operation @s score *= Global score
# -> 3000

別のオブジェクトの値で割る

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)を、Globalのscore(30)で割る(100 / 30)
/scoreboard players operation @s score /= Global score
# -> 3(余りは無視される)

相手のオブジェクトが0の場合は計算されず、元の値がそのまま入ります。 (0で割る計算はできません。)

別のオブジェクトの値で割った余りにする

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)を、Globalのscore(30)で割った余りにする(100 % 30)
/scoreboard players operation @s score %= Global score
# -> 10

相手のオブジェクトが0の場合は計算されず、元の値がそのまま入ります。

別のオブジェクトの値にする

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)に関係なく、Globalのscore(30)にする
/scoreboard players operation @s score = Global score
# -> 30

別のオブジェクトの値と比較して小さいほうにする

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)とGlobalのscore(30)で小さい方にする
/scoreboard players operation @s score < Global score
# -> 30

別のオブジェクトの値と比較して大きいほうにする

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)とGlobalのscore(30)で大きい方にする
/scoreboard players operation @s score > Global score
# -> 100

別のオブジェクトの値と入れ替える

# 自分のscoreを初期化
/scoreboard players set @s score 100
# 自分のscore(100)とGlobalのscore(30)を入れ替える
/scoreboard players operation @s score >< Global score
# -> 30(自分)
# -> 100(Global)
次のページへ
/execute - 自分以外を基準にしてコマンドを実行する