解説動画

解答コード
const ANDESITE_ID: number = 327681; // 安山岩
const BASALT_ID: number = 768; // 玄武岩
const DIORITE_ID: number = 196609; // 閃緑岩
const GRANITE_ID: number = 65537; // 花崗岩
const IRON_ORE_ID: number = 15; // 鉄鉱石
const DIAMOND_ORE_ID: number = 56; // ダイヤモンド鉱石
const EMERALD_ORE_ID: number = 129; // エメラルド鉱石
const GOLD_ORE_ID: number = 14; // 金鉱石
function placeOre() {
agent.move(DOWN, 1);
let baseId: number = agent.inspect(AgentInspection.Block, DOWN);
player.say("基盤岩の番号は " + baseId + " です");
agent.move(UP, 1);
let oreId: number = 0;
switch (baseId) {
case ANDESITE_ID:
oreId = IRON_ORE_ID;
break;
case BASALT_ID:
oreId = DIAMOND_ORE_ID;
break;
case DIORITE_ID:
oreId = EMERALD_ORE_ID;
break;
case GRANITE_ID:
oreId = GOLD_ORE_ID;
break;
default:
break;
}
player.say("鉱石の番号は " + oreId + " です");
if (oreId > 0) {
agent.setSlot(1);
agent.setItem(oreId, 1, 1);
agent.place(DOWN);
}
}
player.onChat("19-1", function () {
player.say("一直線に並んだ基盤岩の上に鉱石を置きます");
for (let i: number = 0; i < 4; i++) {
agent.move(FORWARD, 1);
placeOre();
}
player.say("鉱石を置きました");
});