본문으로 건너뛰기
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개를 앞으로

🌱 seedling
on 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칸

🌱 seedling
on 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🌿 herb
on 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🌳 tree
on 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🌳 tree
on 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] = 방향 전환