Day 2 · MakeCode
자동 건축가
반복 한 방으로 100개 건축!
학습 목표
- ✓repeat(반복) 블록으로 같은 일을 여러 번 시키기
- ✓에이전트 place on move 자동 배치 모드 사용하기
- ✓에이전트 방향(6방향)과 turn 이해하기
- ✓for 카운터로 번호가 있는 반복 만들기
핵심 개념
repeat = 복사기!
repeat (10) times { ... } → 안에 있는 코드를 10번 반복! 100번 복붙 대신 블록 하나로 끝!
place on move = 자동 배치
에이전트가 움직일 때마다 자동으로 블록 놓기! 켜기 → 이동 → 끄기 3단계!
데모 코드
데모
에이전트로 벽 10칸!
on chat command "줄" {
agent teleport to player
agent set item [STONE] count (64) in slot (1)
agent set active slot (1)
repeat (10) times {
agent place [forward]
agent move [right] by (1)
}
}JavaScript 참고 (🌳)
player.onChat("줄", function () {
agent.teleportToPlayer();
agent.setItem(STONE, 64, 1);
agent.setSlot(1);
for (let i = 0; i < 10; i++) {
agent.place(FORWARD);
agent.move(RIGHT, 1);
}
});💡 repeat 하나로 돌 10개가 오른쪽으로!
데모
기둥 — 위로 쌓기!
on chat command "기둥" {
agent teleport to player
agent set item [OAK LOG] count (64) in slot (1)
agent set active slot (1)
repeat (8) times {
agent place [down]
agent move [up] by (1)
}
}JavaScript 참고 (🌳)
player.onChat("기둥", function () {
agent.teleportToPlayer();
agent.setItem(LOG_OAK, 64, 1);
agent.setSlot(1);
for (let i = 0; i < 8; i++) {
agent.place(SixDirection.Down);
agent.move(UP, 1);
}
});💡 place [down] + move [up] = 기둥!
데모
place on move — 걸으면 블록이!
on chat command "자동길" {
agent teleport to player
agent set item [STONE BRICKS] count (64) in slot (1)
agent set active slot (1)
agent set assist [place on move] to [on]
agent move [forward] by (10)
agent set assist [place on move] to [off]
}JavaScript 참고 (🌳)
player.onChat("자동길", function () {
agent.teleportToPlayer();
agent.setItem(STONE_BRICKS, 64, 1);
agent.setSlot(1);
agent.setAssist(PLACE_ON_MOVE, true);
agent.move(FORWARD, 10);
agent.setAssist(PLACE_ON_MOVE, false);
});💡 move 한 번으로 10칸 길!
데모
계단 만들기!
on chat command "계단" {
agent teleport to player
agent set item [STONE BRICK STAIRS] count (64) in slot (1)
agent set active slot (1)
repeat (8) times {
agent place [down]
agent move [forward] by (1)
agent move [up] by (1)
}
}JavaScript 참고 (🌳)
player.onChat("계단", function () {
agent.teleportToPlayer();
agent.setItem(STONE_BRICK_STAIRS, 64, 1);
agent.setSlot(1);
for (let i = 0; i < 8; i++) {
agent.place(SixDirection.Down);
agent.move(FORWARD, 1);
agent.move(UP, 1);
}
});💡 앞으로 1 + 위로 1 = 대각선 = 계단!
실습
빈칸을 채우고 정답을 확인해보세요!
유리 블록 7개를 앞으로
🌱 seedlingon chat command "유리길" { agent teleport to player agent set item [GLASS] count (64) in slot (1) agent set active slot (1) agent set assist [place on move] to [on] agent move [forward] by () agent set assist [place on move] to [off] }
다이아 탑 10칸
🌱 seedlingon chat command "다이아탑" { agent teleport to player agent set item [] count (64) in slot (1) agent set active slot (1) repeat () times { agent place [down] agent move [up] by (1) } }
계단 만들기
🌱 seedling🌿 herbon chat command "내계단" { agent teleport to player agent set item [STONE BRICK STAIRS] count (64) in slot (1) agent set active slot (1) repeat (6) times { agent place [] agent move [] by (1) agent move [] by (1) } }
💡 발밑에 놓고 → 앞으로 → 위로 = 계단!
가로등 5개
🌿 herb🌳 treeon chat command "가로등길" { agent teleport to player agent set item [OAK FENCE] count (64) in slot (1) agent set item [GLOWSTONE] count (64) in slot (2) repeat (5) times { agent set active slot (1) repeat () times { agent place [down] agent move [up] by (1) } agent set active slot (2) agent place [down] agent move [down] by () agent move [right] by (3) } }
💡 반복 안에 반복 = 중첩 repeat! 올라간 높이만큼 내려와야 해요.
다리 만들기
🌿 herb🌳 treeon chat command "다리" { agent teleport to player agent set item [OAK PLANKS] count (64) in slot (1) agent set item [OAK FENCE] count (64) in slot (2) // 바닥 agent set active slot (1) agent move [up] by (3) agent set assist [place on move] to [on] agent move [forward] by (12) agent set assist [place on move] to [off] // 난간 agent set active slot (2) agent teleport to player agent move [up] by () agent set assist [place on move] to [on] agent move [forward] by (12) agent set assist [place on move] to [off] }
블록 이름 검색
명령어에 쓸 블록 이름을 검색하세요 (영어 또는 한국어)
돌/벽돌나무광물색상유리특수유틸
stone돌돌/벽돌cobblestone조약돌돌/벽돌stone_bricks돌벽돌돌/벽돌brick_block벽돌돌/벽돌sandstone사암돌/벽돌obsidian흑요석돌/벽돌bedrock기반암돌/벽돌oak_planks참나무 판자나무spruce_planks가문비나무 판자나무birch_planks자작나무 판자나무dark_oak_planks짙은 참나무 판자나무oak_log참나무 통나무나무oak_fence참나무 울타리나무oak_stairs참나무 계단나무gold_block금 블록광물diamond_block다이아몬드 블록광물iron_block철 블록광물emerald_block에메랄드 블록광물white_wool하얀 양털색상red_wool빨간 양털색상orange_wool주황 양털색상yellow_wool노란 양털색상green_wool초록 양털색상blue_wool파란 양털색상purple_wool보라 양털색상black_wool검정 양털색상brown_wool갈색 양털색상gray_wool회색 양털색상white_concrete하얀 콘크리트색상red_concrete빨간 콘크리트색상blue_concrete파란 콘크리트색상green_concrete초록 콘크리트색상black_concrete검정 콘크리트색상glass유리유리stained_glass색유리유리glowstone발광석특수torch횃불특수lantern랜턴특수sea_lantern바다 랜턴특수water물특수lava용암특수grass잔디 블록특수sand모래특수dirt흙특수air공기특수tntTNT특수chest상자유틸crafting_table제작대유틸furnace화로유틸bed침대유틸rail레일유틸golden_rail파워 레일유틸command_block커맨드 블록유틸chain_command_block체인 커맨드 블록유틸repeating_command_block반복 커맨드 블록유틸자유 도전
실습이 끝났으면 티어에 맞는 도전을 골라보세요!
A🌱
긴 울타리 + 가로등
실습 4 코드에서 숫자만 바꿔보기! 가로등 8개, 간격 4칸
B🌿
사각형 길
place on move 켜고 forward 10 → turn right × 4번 = 사각형!
C🌿
성벽
가로 20칸 벽 + 양쪽 끝에 기둥 5칸
D🌳
자유 대형 건축물!
repeat + place on move + turn 조합! 최소 repeat 2번, 방향 3가지
Day 2 핵심 정리
- 🎯repeat (N) times { ... } = 복사기! N번 반복
- 🎯place on move = 자동 배치! 켜기 → 이동 → 끄기
- 🎯에이전트 6방향: forward/back, left/right, up/down
- 🎯agent turn [left/right] = 방향 전환