解説動画
解答コード
function cloneLine13_5() {
// 配列の中のブロックをおいていく
arr.forEach(function (element) {
agent.setItem(element, 1, 1);
agent.place(FORWARD);
agent.move(UP, 1);
});
agent.move(DOWN, arr.length); // arr.length → 配列の中にある要素の数
}
function inspectLine() {
arr = [];
// 5ブロック読み込む
for(let i = 0; i < 5; i++) {
let block_type = agent.inspect(AgentInspection.Block, FORWARD);
// ブロックのデータを配列に格納する
arr.push(block_type);
agent.move(UP, 1);
}
agent.move(DOWN, 5);
}
player.onChat("13-5", function () {
// 読み込み
inspectLine();
// 1本目
agent.turn(RIGHT_TURN);
cloneLine13_5();
// 2本目
agent.move(RIGHT, 9);
agent.turn(RIGHT_TURN);
cloneLine13_5();
// 3本目
agent.move(RIGHT, 6);
cloneLine13_5();
});