Lua

Dice Engine: Roll 2d6+1, Repeatably

Write a parser for dice notation like 2d6+1 and a seeded roller, so every tabletop roll is repeatable, testable, and provably fair.

LuaIntermediateFor fun, and portfolio-worthy

What you'll be able to build

Write a parser for dice notation like 2d6+1 and a seeded roller, so every tabletop roll is repeatable, testable, and provably fair. Along the way you pick up real, transferable Lua skills, not just this one project:

  • string pattern matching with :match and captures
  • tonumber and safe defaults (or fallbacks)
  • math.randomseed and math.random for deterministic RNG
  • building and returning multiple values
  • accumulators and numeric for loops
  • table.concat for clean reporting

A course like this one

Yours is built from your own placement, so module count and depth will differ. This map shows what a intermediate-level Lua learner building Dice Engine actually gets.

  1. Module 1: Values, tables, and output5 lessons

    Builds the script for your dice engine.

  2. Module 2: Tables as data: arrays, records, and lookups5 lessons

    Builds the table model workflow for your dice engine.

  3. Module 3: Control flow and truthiness5 lessons

    Builds the function that powers your dice engine.

  4. Module 4: Functions, varargs, and errors5 lessons

    Builds the reusable module for your dice engine.

  5. Module 5: Metatables, coroutines, and program design5 lessons

    Builds the metatable behaviour for your dice engine.

  6. Module 6: Packaging and release readiness3 lessons

    Builds the release package for your dice engine.

How the lessons actually work

Leans on:mathstringtable

Every lesson has you predict what a piece of Lua code will output before you run it, then run it for real in your browser and fix what you got wrong. Each module ends in a challenge gate with hidden tests, so you can't advance until your code actually works. The course closes with a capstone that assembles everything into Dice Engine, and a runnable proof page tied to your own code.

Common questions

How long does the Dice Engine: Roll 2d6+1, Repeatably course take?

about 7 hours, across 6 modules and 28 lessons, at roughly 15 minutes per lesson. Your own course may run shorter or longer, since it's sized to your placement result, not a fixed template.

Do I need experience?

Some. This is an intermediate-tier Lua project, so it assumes you're comfortable with Lua basics and pushes past them.

How much does it cost?

$15 one-time, no subscription. The first module is free, so you can see exactly how the course teaches before you pay for the rest.

No subscription. Module one is free.

Build my Dice Engine