Text-Based Dungeon Crawler
Build a dungeon crawler game in Lua for the terminal: you explore a dungeon room by room, pick up weapons, potions and keys, fight monsters in turn-based battles with dice rolls, and try to defeat the boss in the final room without running out of health. The whole dungeon, rooms, monsters and items, is described in Lua tables, so you can design new levels without changing the game code. It's a fun first Lua project: you'll learn tables for data and objects, loops and conditions, reading player commands, random numbers with math.random, and organizing a small game into functions.
- Estimate
- ~8h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Lua standard library
Project roadmap
- 01
Design the dungeon
~1.5hWrite the dungeon as a Lua table: rooms with a name, description, exits (such as north = "hall"), items and an optional monster; monsters with name, health, attack and defense; and items (weapons adding attack, potions restoring health, and keys opening locked doors). Include at least 8 rooms and a boss room behind a locked door. Done when: the dungeon table loads, and a small script prints every room and its exits.
- 02
Build the game loop
~1.5hWrite the main loop: describe the current room, read a command with io.read, and handle go DIRECTION, look, take ITEM and inventory, plus help and quit. Refuse to leave through a locked door without the key, and block moving past a monster until it's defeated. Done when: the player can walk around the dungeon and pick up items.
- 03
Add combat
~2hImplement turn-based combat: attack rolls a die with math.random (seeded with os.time()), adds the attacker's attack minus the defender's defense (at least 1 damage), and both sides take turns until one reaches 0 health. Let the player drink a potion or flee to the previous room during a fight. Print each turn clearly. Done when: fights play out turn by turn, and fleeing and potions work.
- 04
Add the inventory
~1hKeep the player's items in a table, with use ITEM for potions and keys and equip ITEM for weapons (only one equipped at a time, changing the attack). Show health, attack and equipped weapon in the inventory command. Done when: items can be used and equipped with the right effects.
- 05
Add winning and losing
~1hEnd the game with a victory message when the boss is defeated, showing the number of moves and monsters defeated, and with a game over message when health reaches 0, offering to play again with a fresh copy of the dungeon. Done when: both endings work, and restarting resets the dungeon.
- 06
Test it
~1hMove the combat and movement rules into functions that don't read input, and test them with plain assert (or busted), fixing the random seed so results are repeatable: damage calculation, locked doors, taking items, potions, and a full fight. 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