Text Adventure
Build a text adventure game in Lua that you play in the terminal: you explore rooms by typing commands such as go north, look, take key, use key on door and inventory, solve small puzzles, and try to reach the end. The whole world (rooms, exits, items and puzzles) is described in a data file, so new adventures can be written without changing the code. You can save your progress to a file and load it later, and loading always restores exactly the same game. It's a great first Lua project: you'll learn tables for modeling a world, string handling to understand commands, game state, reading and writing files, and testing game logic.
- Estimate
- ~9h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Lua · busted
Project roadmap
- 01
Design the world format
~1hWrite README.md with a small example world as a Lua data file: rooms (id, name, description, exits such as north = "hall"), items (id, name, description, where they start, whether they can be taken) and simple puzzles (a locked exit that opens when a certain item is used). List every command and what it prints. Done when: README.md describes the world format and all commands.
- 02
Load and check the world
~1.5hLoad the world file with loadfile in an empty environment, so it can only contain data. Check it: every exit leads to a room that exists, every item starts in a real room, ids are unique, and the start room exists. Report all problems together. Done when: a correct world loads, and a world with a broken exit reports it clearly.
- 03
Understand commands
~1.5hWrite a parser that lowercases the input, splits it into words, removes filler words (the and a), and recognizes verbs with their synonyms (go and walk, take and get, and single-letter directions such as n). Return the verb and its objects, or a friendly message when the command isn't understood. Done when: go north, n and walk to the north all mean the same thing.
- 04
Play the game
~2hWrite the game loop: show the current room's description, exits and visible items, read a command and run it: move, look, take and drop items, inventory, examine, and use item on something to solve puzzles. Count moves, and end the game with a message when the goal room is reached. Done when: the example world can be played from start to finish.
- 05
Save and load
~1.5hAdd save NAME and load NAME commands that store the game state (current room, inventory, item locations, opened exits and move count) in a file, written in a fixed order so the same state always produces the same file. Loading checks the save matches the world and restores it exactly. Done when: saving, quitting and loading continues the game exactly where it was.
- 06
Test it
~1.5hWrite tests (with busted or plain assert) that run a sequence of commands against the example world and check the results: moving through exits, blocked exits, taking and using items, solving the puzzle, invalid commands, and a save then load giving the same state. Done when: the tests pass.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack