バックグラウンドで実行する loops.runInBackground
ひとことで言うと
現在のコードと並行してこのコードを実行します。
ブロックとコード
バックグラウンドで実行する
ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。
loops.runInBackground(function () {
})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)