Lua Fundamentals

Lesson 6 of 6

Final Project: Build a Text Adventure Game in Lua

Put tables, functions, and control flow together into a small, playable text adventure.

Requirements

  1. 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" }).
  2. Track the player's current room and inventory (a table used as a list) in local state.
  3. 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.
  4. Use functions to organize the logic, at minimum, a function to describe the current room and a function to handle a single command.
  5. 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 require it 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! 🚀

This lesson ends in a project. Build it on your own machine, there's nowhere to submit it here, but the brief above is everything you need.