Final Project: Build a Text Adventure Game in Lua
Put tables, functions, and control flow together into a small, playable text adventure.
Requirements
- Model at least three rooms as a table of tables, each with a description and a table of exits (e.g.
{ north = "cave", south = "forest" }). - Track the player's current room and inventory (a table used as a list) in local state.
- Write a main loop that prints the current room's description, reads a command from the player, and reacts to at least: moving through an exit, picking up an item, and checking inventory.
- Use functions to organize the logic, at minimum, a function to describe the current room and a function to handle a single command.
- Add a win condition, e.g. reaching a specific room, or collecting a specific item, that ends the loop with a victory message.
Stretch goals
- Use a metatable so every room and item shares common behavior (like a generic
:describe()method). - Split your rooms/items data into a separate module file and
requireit from your main script. - Add simple combat or a puzzle that requires an item from one room to progress past another.
Submit a link to your finished script (a repo or gist) below, an instructor will review it before you can mark this lesson complete. Good luck! 🚀