チャットコマンドを引数付きで実行する player.runChatCommandWithArguments

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

ひとことで言うと

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

ブロックとコード

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

引数(ひきすう)

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

名前選べる値意味
command文字列実行するチャットコマンド。たとえば:「jump」
arg文字列チャット コマンドで利用したいすべての引数を含む文字列

使用例

Let's say you have a chat command in your project that makes your agent build a row of blocks of variable length:

JavaScript

player.onChat("row", function (length) {
    for (let i = 0; i < length; i++) {
        agent.move(FORWARD, 1);
        agent.place(BACK);
    }
})

Python

def on_on_chat(length):
    for i in range(length):
        agent.move(FORWARD, 1)
        agent.place(BACK)
player.on_chat("row", on_on_chat)

You can reuse this chat command in other parts of your code to build a square, for example:

JavaScript

player.onChat("square", function () {
    agent.teleportToPlayer()
    agent.move(FORWARD, 1)
    for (let i = 0; i < 4; i++) {
        player.runChatCommandWithArguments("row", "5")
        loops.pause(5000)
        agent.turn(TurnDirection.Left);
        agent.move(FORWARD, 1)
        agent.move(LEFT, 1)
    }
});

Python

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