解説動画
解答コード
// 5種類の床材を順番に設置
let dic_item174: { [key: string]: number } = {
"MossyCobblestone": 48, // 苔むした丸石
"IronBlock": 42, // 鉄ブロック
"LightGrayConcrete": 524524, // 薄灰色のコンクリート
"Cobblestone": 4, // 丸石
"GrayConcrete": 458988 // 灰色のコンクリート
};
function placeFloorRow174(motion: { [key: string]: number }, pattern: string[]) {
// 開始位置の穴まで移動
agent.move(FORWARD, motion["forward"]);
agent.move(RIGHT, motion["right"]);
// 床ブロックを右から左へ順番に置く
for (let i = 0; i < pattern.length; i++) {
agent.setItem(dic_item174[pattern[i]], 1, 1);
agent.place(DOWN);
agent.move(LEFT, 1); // 次の穴へ移動
}
}
player.onChat("17-4", () => {
let floorPattern = ["MossyCobblestone", "IronBlock", "LightGrayConcrete", "Cobblestone", "GrayConcrete"];
let agentMotion: { [key: string]: number } = {
"forward": 1, // 開始位置への移動距離(前へ進む歩数)
"right": 0 // 開始位置への移動距離(右へ進む歩数)
};
// 1列目を設置
placeFloorRow174(agentMotion, floorPattern);
// 2列目を設置
agentMotion["right"] = 4;
placeFloorRow174(agentMotion, floorPattern);
});