방 연결하기
Coddy Lua 여정의 Logic & Flow 섹션에 포함된 레슨 — 54개 중 25번째.
챌린지
쉬움시작 방을 바탕으로 두 번째 방을 만들고, 각 방의 exits 테이블을 통해 두 방을 서로 연결하세요.
이전 챌린지에서 만든 startingRoom 변수("Ancient Library")가 제공됩니다.
다음 세부 정보를 사용하여 gardenRoom이라는 새로운 방을 만드세요:
name: "Secret Garden"description: "A hidden garden with overgrown plants and a small fountain."exits: 빈 테이블
두 방에 각각 출구를 추가하여 서로 연결하세요:
startingRoom에서"east"로 가면gardenRoom으로 이어지는 출구를 추가하세요.gardenRoom에서"west"로 가면 다시startingRoom으로 이어지는 출구를 추가하세요.
시작 방의 이름을 출력하고, 시작 방에서 동쪽(east)으로 갔을 때 도착하는 방의 이름을 출력한 다음, 그 방에서 다시 서쪽(west)으로 갔을 때 도착하는 방의 이름을 출력하세요.
예상 출력 형식:
Ancient Library
Secret Garden
Ancient Library직접 해보기
local startingRoom = {
name = "Ancient Library",
description = "You find yourself in a dusty library filled with ancient books and scrolls.",
exits = {}
}
print(startingRoom.name)
print(startingRoom.description)