Menu
Coddy logo textTech

部屋の連結

CoddyのLuaジャーニー「Logic & Flow」セクションの一部 — レッスン 25/54。

challenge icon

チャレンジ

簡単

前のステップで作成した開始の部屋を基に、2つ目の部屋を作成し、それぞれの exits テーブルを通じて両方の部屋をリンクさせましょう。

前のチャレンジで作成した startingRoom 変数(Ancient Library)が提供されています。

以下の詳細を持つ gardenRoom という新しい部屋を作成してください:

  • name: "Secret Garden"
  • description: "A hidden garden with overgrown plants and a small fountain."
  • exits: 空のテーブル

両方の部屋に出口を追加して、2つの部屋をリンクさせます:

  • 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)

Logic & Flowのすべてのレッスン