连接房间
本课属于 Coddy Lua 学习旅程的“逻辑与流程”单元。第 25 课,共 54 课。
挑战
简单在起始房间的基础上,创建第二个房间,并通过它们的 exits 表将两个房间连接起来。
你可以使用上一个挑战中的 startingRoom 变量(Ancient Library)。
创建一个名为 gardenRoom 的新房间,包含以下信息:
name: "Secret Garden"description: "A hidden garden with overgrown plants and a small fountain."exits:一个空表
为两个房间添加出口,将它们连接起来:
- 从
startingRoom添加一条通往gardenRoom的"east"出口 - 从
gardenRoom添加一条通往startingRoom的"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)逻辑与流程中的所有课
自己练习: Lua 在线编译器