チャットコマンドを実行する player.runChatCommand

プレイヤー公式データ取得日:2026年11月13日Python:player.run_chat_command動作確認待ち

ひとことで言うと

コード内でチャットコマンドを実行します。

ブロックとコード

ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。

引数(ひきすう)

引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。

名前選べる値意味
command文字列実行するチャットコマンド。たとえば:「jump」

使用例

Let's say you have a chat command in your project that makes your agent move forward and place a block:

JavaScript

player.onChat("placeforward", function () {
        agent.move(FORWARD, 1);
        agent.place(BACK);
});

Python

def on_on_chat():
    agent.move(FORWARD, 1)
    agent.place(BACK)
player.on_chat("placeforward", on_on_chat)

You can reuse this chat command in other parts of your code to have your agent build a row:

JavaScript

player.onChat("row", function () {
    agent.teleportToPlayer();
    for (let i = 0; i < 5; i++) {
        player.runChatCommand("placeforward");
    }
});

Python

def on_on_chat():
    agent.teleport_to_player()
    for i in range(5):
        player.run_chat_command("placeforward")
player.on_chat("row", on_on_chat)
執筆:鈴木孝昌官公庁のWeb・システム開発を担当する現役プロジェクトマネージャー。マイクラカップ沖縄代表チームを指導(第6回・第7回、第7回TBS賞)。
沖縄マイクラ部で、子どもたちにMakeCodeを教えています。プロフィールと編集方針
Instagramで教室の様子を見る
noteで記事を読む