保存した構造物を削除する blocks.deleteStructure
ひとことで言うと
保存しておいた構造物を、名前を指定して削除するブロックです。
ブロックとコード
"my structure"という名前の構造物を削除する
ブロックの文言は公式の日本語版に合わせています(形は簡易表示です)。
blocks.deleteStructure("my structure")blocks.delete_structure("my structure")引数(ひきすう)
引数とは、ブロックの中で自分で選んだり入力したりする部分のことです。
| 名前 | 選べる値 | 意味 |
|---|---|---|
| name | 文字列 |
使用例
Make a chat command to build a fenced corral that surrounds the player. Fill the corral with some horses. Save the horse corral as a structure so you can load it somewhere in the world later. Also, make a chat command to remove the corral from memory.
JavaScript
player.onChat("makecorral", function () {
blocks.fill(
SPRUCE_FENCE,
pos(-20, 0, -20),
pos(20, 0, 20),
FillOperation.Outline
)
for (let index = 0; index < 10; index++) {
mobs.spawn(HORSE, randpos(
pos(-19, 0, -19),
pos(19, 0, 19)
))
}
blocks.saveStructure(
"horse corral",
pos(-20, 0, -20),
pos(20, 0, 20)
)
})
player.onChat("removecorral", function () {
blocks.deleteStructure("horse corral")
})Python
def on_on_chat():
blocks.fill(SPRUCE_FENCE,
pos(-20, 0, -20),
pos(20, 0, 20),
FillOperation.OUTLINE)
for index in range(10):
mobs.spawn(HORSE, randpos(pos(-19, 0, -19), pos(19, 0, 19)))
blocks.save_structure("horse corral", pos(-20, 0, -20), pos(20, 0, 20))
player.on_chat("makecorral", on_on_chat)
def on_on_chat2():
blocks.delete_structure("horse corral")
player.on_chat("removecorral", on_on_chat2)