バックグラウンドで実行する loops.runInBackground

ループ公式データ取得日:2026年11月13日Python:loops.run_in_background動作確認待ち

ひとことで言うと

現在のコードと並行してこのコードを実行します。

ブロックとコード

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

使用例

Have the agent build a tower while you wait for the player to type the "jump" command.

JavaScript

loops.runInBackground(function () {
    for (let i = 0; i < 6; i++) {
        for (let j = 0; j < 4; j++) {
            agent.place(BACK)
            agent.turn(TurnDirection.Right)
            agent.move(FORWARD, 1)
            loops.pause(2000)
        }
        agent.move(UP, 1)
    }
})
player.onChat("jump", function () {
    player.teleport(pos(0, 0, 100))
})

Python

def on_run_in_background():
    for i in range(6):
        for j in range(4):
            agent.place(BACK)
            agent.turn(TurnDirection.RIGHT)
            agent.move(FORWARD, 1)
            loops.pause(2000)
        agent.move(UP, 1)
loops.run_in_background(on_run_in_background)

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