# バックグラウンドで実行する(loops.runInBackground) > 現在のコードと並行してこのコードを実行します。 - カテゴリ:ループ(loops) - ブロック:バックグラウンドで実行する - URL:https://makecode.minecraft-okinawa.com/reference/loops/run-in-background/ - Pythonでの名前:loops.run_in_background - 公式データ取得日:2026-11-13 - 動作確認:確認待ち ## JavaScript ```javascript loops.runInBackground(function () { }) ``` ## Python ```python def on_run_in_background(): pass loops.run_in_background(on_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) ``` ## 出典 - [MakeCode for Minecraft 公式リファレンス(loops.runInBackground)](https://minecraft.makecode.com/reference/loops/run-in-background) 執筆:鈴木孝昌(現役プロジェクトマネージャー/マイクラカップ指導者)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)