The magic rainbow block

Learn to make mods

One new word. One new thing you can see. Then stop and play with it.

0%
Flipping this changes what shows, never what is saved.

Brand new computer? Go back one tab to 0 ยท Set up the computer and do those seven things first. If that's already done, you're in exactly the right place.

The one big idea

A computer is very obedient and very forgetful.

It does exactly what you tell it. And it knows nothing until you tell it.

A mod is a list of orders you write down. When the game wakes up, it reads your list from top to bottom and does what it says. Anything you never told it about? It never happened. Not hidden. Not locked. Just never heard of.

That's the whole trick. Every level here is just giving more orders.

Three words you will use every day

WordKid wordsWhat it really is
registerTell the computer a NEW THING existsAdding a definition to the game's lists
nodeA block you can put in the worldA block type (dirt, glass, rainbow)
printMake the computer say something we can seeWriting a line to the log

Why each level has one new word If four things are new at once, nothing sticks. One thing, seen working, remembered.

The Loop ๐Ÿ”

Every time you change anything, you do the same four beats. All day. Every level.

โœ๏ธ1. change one word in your code
โ†“
๐Ÿง‘2. a grown-up puts your change into the game for yougrown-up types ./deploy.sh -r magic
โ†“
๐Ÿ‘€3. the log answers back
โ†“
๐Ÿง’4. go look in the game
โ†บ back to 1

The rule Nothing in the game changes until the server wakes up again. There is no "save and it appears". Restart IS the reload. This feels slow for ten minutes, then it becomes the most normal thing in the world.

Who does what

๐Ÿง’ Jonathan Reads every line out loud. Picks the words. Draws the pictures. Looks in the game and says whether it's right โ€” only you can see that part.
๐Ÿง‘ Grown-up Types into the terminal. Presses restart. Keeps the backups. Never fixes it by guessing.

Two rules about names

These two rules break more blocks than everything else combined.

Rule 1 Everything you make starts with magic: โ€” that's your family. Nobody else's block can ever bump into yours.
Rule 2 A picture's filename starts with magic_ and matches the code exactly. Same letters, same underscore โ€” or you get the purple "I don't know" block.

If today went sideways

Nothing can be lost. The folder mods/magic in the repo is always the truth. A grown-up puts that folder back the way it wasGrown-up runs ./deploy.sh -r magic and the repo copy goes back into the game โ€” and the copy that was in the game got saved in .backups/ first, automatically.

A rule we keep Never stop for the day with it broken. Go back to the last thing that worked. A mod that was reverted still taught you something. A broken mod at bedtime teaches you to hate this.

Level 0 ยท Setting up your computer ๐Ÿ–ฅ๏ธ

Before we make a single block, we get the computer ready. Seven things. Each one has a reason, and each one has one small job that is yours โ€” so you always know what changed.

Already have all of this? Walk the seven steps and tick only what you genuinely have. If they are all ticked, go straight to Start here โ€” this chapter is for a machine that has never done any of it. It is not a test and nobody is grading you.
Decide one thing before you install anything There are two ways to play, and the choice changes almost every step below. Way 1: the game runs on this computer. Way 2: the game runs on a server and this computer only writes the mod. Read two-ways-to-play.md once, pick, then come back. Everything from step 2 onward is the same either way except step 7.
1

One folder for everything ๐Ÿ“

Why we do this When all our things live in one place, the computer always knows where to look, and so do you. Scattered files are the number one reason a lesson gets stuck and nobody knows why.

Your job Make one folder on this computer. Call it luanti. Everything we ever make goes inside it. Nothing goes in your Downloads folder โ€” that place is a swamp.
Grown-up does Make it somewhere calm and local. Do not put it inside OneDrive, iCloud, Google Drive or Dropbox: cloud sync fights the editor while it saves and can hold the file open while the game tries to read it. That produces bugs that are completely impossible to see.
  • Linux: mkdir -p ~/luanti
  • macOS: make it under your home folder, e.g. ~/luanti
  • Windows: C:\luanti beats a synced Documents folder
2

Git โ€” a camera for your work ๐Ÿ“ธ

Why we do this git takes a photograph of every file every time you tell it to. Those photographs are saved forever. Break something badly on purpose or by accident? You go back to any photograph you ever took. It is the best undo button that exists, and it works even if you deleted the file.

Say it out loud "A commit is a photograph of all my work. I can always go back to a photograph."
Your job When your grown-up makes the first commit, watch the list of files go by and say "cheese". Yes, really. That is the moment it becomes a camera and not a scary word.
Grown-up does Install git (every OS has a package for it), then tell it who you are so every photograph has a name on it:
git config --global user.name  "your-name"
git config --global user.email "you@example.com"
Then get the lessons: git clone <this repo> ~/luanti/tutorial. Do one commit together โ€” git status, then git add, then git commit -m "..." โ€” and let the child press Enter. Ten seconds, and the word stops being scary forever.
3

Pixelorama โ€” where you draw your blocks ๐ŸŽจ

Why we do this Every block you will ever make needs a skin. Pixelorama is where you draw that skin. The game uses tiny pictures โ€” 16 ร— 16 dots โ€” and a tiny picture drawn by you looks better than a huge one drawn by nobody.

Your job Open Pixelorama. Make a new picture that is 16 wide and 16 tall. Draw absolutely anything โ€” a face, a heart, a weird blob. Save it. You just made the thing every level needs.
Grown-up does Install Pixelorama (it is free, and there is a build for Linux, macOS, Windows and in a browser). Two things worth knowing now, because they cause the purple "unknown block" later:
  • Our pictures must be named <modname>_<thing>.png โ€” e.g. magic_rainbow.png. The prefix is not decoration.
  • The file goes inside mods/<mod>/textures/, and the name in the code and the name on disk must match character for character.
4

The code editor โ€” and not Notepad ๐Ÿ–‹๏ธ

Why we do this A code editor paints the different kinds of word in different colours. That colour is how you see a missing quote or a bracket that never closed before the game has to complain about it. Word processors do the opposite โ€” they hide and "fix" characters, which breaks code silently.

Never for code Microsoft Word, Google Docs, Apple Pages, WordPad. They are not editors for code and they will quietly ruin the file.
Your job Open the editor your grown-up installed. Open the file mods/magic/init.lua. Point at a word and tell me what colour it is. That colour is information.
Grown-up does Install one plain-text code editor: VS Code, Lite XL, Lapce, Sublime, Kate, or nano/vim if that is your preference. Anything that opens plain text and colours Lua works. Whatever you pick, make it the thing the child sees you use โ€” and pin the mods/ folder so the file tree is always visible.
5

The game itself โ€” Luanti ๐ŸŽฎ

Why we do this You cannot learn to mod a game you cannot open. You need the game running and your own world to break in.

Your job Open Luanti. Make a new world and give it a name you like. Then find the creative setting โ€” that is the mode where you can pick up anything, which means Level 1 can actually appear in your bag.
Grown-up does
  • Way 1: install Luanti on this machine and start it. Find the world folder by looking at what the game shows you โ€” never guess it (Flatpak and Snap hide it deep under ~/.var).
  • Way 2: the game already runs on the server. Do nothing here except make sure you can connect to it and the world loads.
  • Either way: creative mode on. Without it the child cannot find the block and will conclude the mod failed.
6

The terminal โ€” talking with your fingers ๐Ÿ’ป

Why we do this The terminal is a place where you tell the computer things by typing whole sentences instead of clicking. Every "get it into the game" step happens here. It looks intimidating for about four minutes and then it is the normal place you live.

Your job โ€” two commands, that is all Open the terminal. Type pwd and press Enter โ€” that means "where am I?" Then type cd luanti and press Enter, and type pwd again. See how the answer changed? That is all the terminal is: you ask, it answers.
Grown-up does Open a terminal and leave it open for the whole lesson โ€” closing and reopening loses where you were, which is a very confusing thing to debug for a 7-year-old. Linux: your terminal app. macOS: Terminal. Windows: PowerShell, WSL, or Git Bash โ€” and pick one and stay on it, because the paths are different in each.
7

Prove it all works before Level 1 โœ…

Why we do this We check now, on purpose, so that later a broken computer never looks like a broken you. If the tools are proven good at the start, then when something fails in Level 3 we know it is the code โ€” and code can be fixed.

Your job Watch your grown-up run the checks. Count the green ticks out loud. If one is not green, we fix it today, not halfway through a lesson.
Grown-up does โ€” and what each one proves
./deploy.sh --detect โ†’ the script can find the game container and the world path. Proves the pipe exists.
./deploy.sh -l โ†’ it can list the mods in the world. Proves you can actually reach it, not just see it.
./scripts/lint-lua.py mods/*/init.lua โ†’ every mod file is well-formed. Proves the code can be read. (There is no Lua installed anywhere here, so this is the best available check offline.)
./scripts/check-lesson-code.sh โ†’ the page and the lessons say exactly what the game is running. Proves the tutorial is not lying to the child.
Way 2 only: ssh deploy@<server> docker ps โ†’ the deploy key works. Setup for that is docs/deploy-user.md and it is your job, not the child's โ€” see the honesty section in that file about what a docker-group user really is.
Four green lines is the green light. Do not start Level 1 with a red one.
If any of it is still broken Fix it now. A broken setup discovered in the middle of Level 3 does not read as "our computer needs fixing" to a child โ€” it reads as "I am bad at this". It is not you. It is the folder, the path, or the restart. Nothing else.

๐Ÿง‘ Your briefing ยท Level 1 โ€” the rainbow block

What you are actually teaching: register. Not syntax โ€” the idea that the game keeps lists, and a mod adds to those lists. If he gets that one thing, Level 1 has done its job. Everything else on the page exists to make that idea land.

The sentence he should be able to tell you at the end

"I told the computer a new block exists, gave it a name and a picture, and now I can put it in the world."

If he can say that, stop. Do not push further today. Depth comes from repeating the same idea at the next level, not from cramming the next idea into this one.

Before he sits down โ€” do these five things

  1. Ship the mod first. ./deploy.sh -r magic and read the log. You are looking for [magic] My magic mod is awake! If that line is not there, nothing else in this session matters โ€” fix that before you hand him anything.
  2. Prove the page matches the game. ./scripts/check-lesson-code.sh must say PASS. If it does not, he would be reading a description of something that is not running, and every confusion that follows is our fault, not his.
  3. Give him a texture he can replace. The repo ships magic_rainbow.png as a stand-in. Open Pixelorama with a 16ร—16 canvas ready, or have his own drawing already dropped in. Level 1 is much better if the picture is his.
  4. Confirm creative mode is on in his world, or he cannot find the block and will report that the mod failed.
  5. Know where your rollback is: ./deploy.sh -r magic puts the repo copy back, and the copy that was in the game is saved in .backups/ automatically. Say this out loud to yourself before you start. It changes how calm you are at 8pm.

What "working" looks like, so you can answer fast

Log: [magic] My magic mod is awake! and no ModRunError.
Inventory: search rainbow, the block is there, with a picture on it (not a purple/black square).
Placed: it sits where he put it and it glows at light_source = 14.
Purple block: the game is asking "which picture did you mean?" โ€” always a name mismatch between tiles and the file in textures/. Read them side by side with him; do not fix it silently.

The three things that come up every single time โ€” and what to say

He wants to change four things at once. "One thing, then we look. If we change four things and it works, we learned one thing. If it breaks, we learned nothing." This is not being fussy โ€” it is the method.
"It's not in my inventory." "Let's check it woke up." Then go read the log together. You are teaching him the most valuable habit in programming: check the source, not the hope.
He asks you to type it for him. Don't. Read it out loud while he types. Your fingers on his keyboard teaches him nothing; his own fingers typing a thing he can then see working teaches him everything.

What you must not do today

  • Do not add a second new word. One word. The Loop and the two naming rules are already plenty.
  • Do not fix it by guessing. If you are guessing, stop and read the log line again โ€” it is the game asking a specific question.
  • Do not touch world.mt, the map files, or anyone's inventory. Deleting our own single mod folder is the rollback. Everything else is out of bounds.
  • Do not end the day broken. Revert to the last thing that worked. A reverted mod still taught him something; a broken mod at bedtime teaches him to hate this.

Shipping this level โ€” dev only

./deploy.sh -r magic ships to the dev world. That is the only target this page ever asks you for, and it should stay that way.

Promotion to the live server is a separate, deliberate act by you, from your own machine, with your own credentials. It is never a step in a lesson, the child's computer does not hold the key to it, and nothing on this site will ever ask him to do it. That rule is in docs/deploy-user.md and it is not optional.

If you only have five minutes

Read two things on this page before he starts: the "Your whole file" block at the bottom, and the "If it broke" table. Those two are what you will be asked about, and knowing them means you can answer in one sentence instead of four.

Level 1 ยท The Magic Rainbow Block ๐ŸŒˆ

You are making a brand new block that has never existed in this game before. You make it, you name it, you draw it, you put it in your world.

When you're finished: a block in your inventory called Magic Rainbow Block that you can place anywhere โ€” and it glows in the dark.

Your one new word register โ€” tell the computer a new thing exists, and give it a name.
Before you start Your grown-up already put Level 1 into the folder and into the game, so there is something real to look at. Steps 1 and 2 are us reading every line together, so you know exactly what each one does. Steps 3, 4 and 5 are yours โ€” you change the real file and watch the game change with it.
1

Say hello ๐Ÿ“ฃ

New word: printMake the computer say something where we can see it.

Our file is called init.lua. init means start. The game reads this file before any other file in the mod.

-- My magic mod. The game reads this file when it wakes up.
print("[magic] My magic mod is awake!")
Read it out loud, in a sentence "Printโ€ฆ open bracketโ€ฆ quoteโ€ฆ magicโ€ฆ close quoteโ€ฆ my magic mod is awakeโ€ฆ close bracket."

The first line starts with --. That means this line is for humans. The computer skips it. Those are called comments.

Grown-up types./deploy.sh -r magic
Look for this line in the log [magic] My magic mod is awake!
If you see it, the computer read YOUR file. Everything we build today stands on that one line. When something breaks later, the first question is always "is it still awake?"
Why the [magic] at all? The log is a big room with dozens of mods shouting at once. [magic] is our name tag so we can hear ourselves in there.
2

REGISTER your first block ๐Ÿช„

Before you register it, the block does not exist. Not hidden behind a door โ€” nobody has ever mentioned it to the computer. After you register it, it is real.

Here is the rest of the file. This is the part that makes the block exist:

core.register_node("magic:rainbow", {
    description = "Magic Rainbow Block",
    tiles = {"magic_rainbow.png"},
    light_source = 14,
})
Read it out loud as four sentences core.register_node( โ†’ "Computer, MAKE A NEW BLOCK."
"magic:rainbow", โ†’ "Its real name is magic colon rainbow."
description = "Magic Rainbow Block", โ†’ "The name people read is Magic Rainbow Block."
tiles = {"magic_rainbow.png"}, โ†’ "Its skin is the picture magic_rainbow.png."
}) โ†’ "That is all the things. Go."

There is one more line in the real file โ€” light_source = 14 โ€” and it is a number we come back to in step 5. Don't touch it yet.

The colon is doing a lot of work

magic : rainbow magic: is our family โ€” every block we make lives here, so nobody else's block can ever bump into ours. rainbow is this block's own name.

To the computer, magic:rainbow and magic :rainbow and magic:Rainbow are three different names. Spaces and capital letters count. The computer never guesses what you meant.

The picture name must match, exactly

file on the disk:   textures/magic_rainbow.png
code says:          tiles = {"magic_rainbow.png"}

Same letters. Same underscore. If they do not match, you get the purple "I don't know what this is" block. That purple block is not an error โ€” it is the game pointing at this exact line and asking "which picture did you mean?"

Grown-up types./deploy.sh -r magic
In the game 1. open your inventory   2. look for Magic Rainbow Block   3. put it in your hand   4. place it where you can see it
You have to tell us whether it looks right We only ever get to see the log. Nobody but you can see the game. "Is it a rainbow?" is a question only you can answer.
3

Change the name tag โœ๏ธ

Change one line. Only the words inside the quotes:

    description = "Jonathan's Super Rainbow",
Grown-up types./deploy.sh -r magic

๐Ÿ‘€ Your block has a new name in the game. Now the important part. You changed the label. Its real name is still magic:rainbow โ€” and you never change that one.

Why never? If you changed the real name, the computer would think you made a different block โ€” and every block you already placed in the world would be left behind holding the old name.

description = what humans read. Free to change.
magic:rainbow = what the computer remembers. Do not change.

4

Draw your own skin ๐ŸŽจ

This is the best part.

1. On your own computer, open Pixelorama โ†’ New image
2. Width 16, height 16. Not 100. 16. That is one block's skin.
3. Draw. Fill every single dot โ€” no empty squares, or your block has holes you can see straight through.
4. Export as PNG, and name the file exactly magic_rainbow.png
5. ๐Ÿง‘ copy it into mods/magic/textures/ on the server โ€” say yes, replace
6. ๐Ÿง’ a grown-up puts it into the game./deploy.sh -r magic
7. ๐Ÿง’ go look in the game.

That is your drawing, as a solid thing you can stand on.

Why 16 ร— 16? Your drawing is 16 ร— 16 dots. When you place the block, the game makes every dot into a square. That is exactly why pixel art looks crisp and blocky โ€” and why squashing a big photo onto a block looks like mud.

Keep your Pixelorama project file. You can always go back, change it, and export again.

5

Make it glow ๐Ÿ’ก

One number to play with. It is already in your file โ€” the last line inside the { }:

    light_source = 14,

Your whole file right now:

-- My magic mod. The game reads this file when it wakes up.
print("[magic] My magic mod is awake!")

core.register_node("magic:rainbow", {
    description = "Magic Rainbow Block",
    tiles = {"magic_rainbow.png"},
    light_source = 14,
})

If you changed the description back in step 3, yours has your words in that line instead. That is allowed โ€” the label is free.

0
nothing
5
small torch
14
nearly the sun
15
the sun
Play with this number Change it to 1. Deploy. Look. Then 5. Then 15. Then dig your block away and place it again at night.
Question to think about Which number makes it a night-light and not a floodlight? There is no wrong answer โ€” but there is a number you picked on purpose. That is the whole point.

If it broke ๐Ÿ”ง โ€” the game is asking you a question

Nothing bad happened. The game told you exactly where it got lost. Fix that one line. Loop again.

What you seeThe game is askingWhat to do
ModRunError + a line number"I got lost on line N โ€” did you close everything?"Look at that line. Count quotes and brackets.
expected ')' near '}'"A bracket is still open from earlier"Find the ( that never got its )
Purple / checkered block"Which picture did you mean?"Is the file magic_rainbow.png, inside textures/, spelled exactly like tiles says?
Block with see-through holes"Some dots are empty"Back to Pixelorama โ€” fill every dot, export again
Nothing new in the inventory"Did you restart at all?"๐Ÿง’ ask a grown-up to put it in the game and look for the awake line./deploy.sh -r magic and look for the awake line
The line is red in the editor"This is not a whole sentence"Missing " or , or )
Panic button โ€” always works ./deploy.sh -r magic โ€” the repo copy goes back into the game, and the old one was saved in .backups/ first. Nothing can be lost.

What you learned today ๐Ÿ†

print = the computer talks back, and that's how you check it heard you
register = make a new thing exist
magic: = your family name, so nothing ever collides
description = the label people read; the real name never changes
tiles = the skin, and the filename must match exactly
light_source = a number you can twist and see
The Loop โ€” change โ†’ deploy โ†’ restart โ†’ look

You did not "play with a game". You wrote instructions a computer obeyed, and you drew the art that made it visible. That is real programming, and it is finished, and it is yours.

Level 2 ยท The Block That Answers When You Touch It ๐Ÿ””

A block that is awake. Right-click it and it says hello to you, by name โ€” and puffs sparkles out of the top.

When you're finished: a block called Answering Chime. Place one down, right-click it, and your own name comes back at you.

Your one new word callback โ€” code that waits. You write it now, it does nothing now, and it runs the moment something happens.
The big jump โ€” read this part twice In Level 1 every line in your file ran once, when the game woke up, and then it was finished forever. A callback is code that runs later, when you are not there. That is the moment a mod stops being a decoration and starts being a machine.
Before you start Your grown-up already put Level 2 into the folder and into the game. Steps 1โ€“4 are us reading every line together. Steps 5 and 6 are yours.
1

A brand new mod ๐Ÿ”ค

Level 2 lives in its own folder: mods/magic_touch. Its first two lines look exactly like the ones you already know:

-- A block that answers when you touch it.
print("[magic_touch] My answering block is awake!")
Grown-up types./deploy.sh -r magic_touch
Look for this line in the log [magic_touch] My answering block is awake!
Now look at the whole log โ€” there are four awake lines, one per mod. That's the roll call. If one is ever missing, that's the one that broke.

Our family name changed

Level 1 was magic:rainbow. This is magic_touch:chime.

magic_touch : chime magic_touch: is this mod's family โ€” the same as its folder name. chime is the block's own name. Two mods can never share a family, the same way two people in the same town can't both be the post office.
2

The same four lines you know, plus one that is new

Read the block and count how much you already recognise:

core.register_node("magic_touch:chime", {
    description = "Answering Chime",
    tiles = {"magic_touch_chime.png"},
    on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)

Four of those lines you already know from Level 1. register_node โ€” make a block. "magic_touch:chime" โ€” its real name. description โ€” the label people read. tiles โ€” the skin.

One line is completely new on_rightclick = function(โ€ฆ
And notice something else The block does not close right after the skin. There is a big lump of code, and then end, and then }). That lump is the new thing. That lump is what a callback looks like.
3

function โ€ฆ end: a bag of things to do later ๐ŸŽ’

Read it out loud as a sentence "When somebody RIGHT-CLICKS this block โ€” run the things that live inside this bag."

That's all function means. It bundles up some instructions and puts them in a bag so they can be run later, when the moment comes. The end at the bottom says that's the end of the bag.

The five presents in the little brackets

Those five names are presents the game hands you at the moment it snaps. You do not fill them in โ€” the game fills them in. You just give them names so you can use them inside the bag.

The nameThe present is
poswhere the block is (its x, y, z)
nodewhich block it is
clickerwho clicked it
itemstackwhat was in their hand
pointed_thingwhat their crosshair was on

You will meet the same presents again at Level 8 with portals. They are always the same presents. Only the bag changes.

4

Your name inside the machine ๐Ÿ“›

        if clicker then
            local name = clicker:get_player_name()
            core.chat_send_player(name, "Ding! Hello, " .. name .. " - you woke me up!")
        end
Read it out loud as three sentences if clicker then โ†’ "If there is actually a person hereโ€ฆ"
local name = clicker:get_player_name() โ†’ "โ€ฆtake their name and keep it in a box called name"
core.chat_send_player(name, โ€ฆ) โ†’ "โ€ฆsend that person a chat message"

The two dots are glue

"Ding! Hello, "  ..  name
       โ†“                โ†“
   "Ding! Hello, "  stuck onto  your real name
       โ†“
   "Ding! Hello, Jonathan - you woke me up!"

That is why the chime says your name and not somebody else's. It was never written in โ€” it got glued on, fresh, from whoever actually clicked.

Why the if at all? Because the bag can sometimes run when there is nobody there. If it tried to greet nobody it would crash. if clicker then means "only do this if there is a real person", and it saves us a whole family of breakages.
Grown-up types./deploy.sh -r magic_touch
In the game 1. find Answering Chime   2. place it where you can see it   3. right-click the chime itself   4. your name comes back at you โœ…
Only you can see whether that worked. We only ever get the log.
5

The sparkle machine โœจ

The last lump inside the bag is one machine with a lot of dials. It looks scary. It is the same idea over and over. add_particlespawner = "puff out a lot of tiny pictures" โ€” each tiny picture is a particle.

The whole trick of this machine Almost every dial comes in a min / max pair. min = the smallest, max = the biggest. For every single sparkle the game picks a random number between the two. That is why no two puffs are ever the same.
DialWhat it controlsOurs
amounthow many sparkles in the puff14
timehow long the puff takes (0.001 = all at once)0.001
minpos / maxposthe box they start in, around the blockjust above it
minvel / maxvelhow fast they flyup and out
minacc / maxacchow gravity pulls them (-4 = down)down
minexptime / maxexptimehow long each sparkle lives, in seconds0.4 โ€“ 1.2
minsize / maxsizehow big each sparkle is0.8 โ€“ 1.6
glowhow shiny, like light_source10
texturethe tiny picture each sparkle wearsmagic_touch_spark.png
Read the whole machine as one sentence "Every time it runs: 14 sparkles, starting somewhere in this box just above the block, flying up and out, pulled down by gravity, each one living between half a second and just over a second, between this size and that size, glowing 10, wearing the picture magic_touch_spark.png."

Why this is worth learning The min/max pattern is all over real game code. Once you can read it here, you can read it anywhere.

6

Yours: the greeting, and one dial โœ๏ธ

1 ยท The words. Change the greeting โ€” anything inside the quotes:

    core.chat_send_player(name, "WAKE UP SLEEPYHEAD, " .. name .. "!")
Keep .. name .. exactly as it is That is the bit that glues your actual name into the message. Delete it and the machine does not know who to greet.

2 ยท One dial. Pick exactly one, redeploy, look:

TryWhat happens
amount = 60a lot more sparkles
glow = 15bright enough to light the block
maxexptime = 4the sparkles hang around for ages
minacc = {x = 0, y = 1, z = 0}gravity up โ€” they float away
Question to think about Which combination feels like fireworks and which feels like dust? There is no wrong answer โ€” but there is one you picked on purpose. That is the whole point.

Your whole file

This is exactly what is in your mods/magic_touch/init.lua right now:

-- A block that answers when you touch it.
print("[magic_touch] My answering block is awake!")

core.register_node("magic_touch:chime", {
    description = "Answering Chime",
    tiles = {"magic_touch_chime.png"},
    on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
        if clicker then
            local name = clicker:get_player_name()
            core.chat_send_player(name, "Ding! Hello, " .. name .. " - you woke me up!")
        end
        core.add_particlespawner({
            amount = 14,
            time = 0.001,
            minpos = {x = pos.x - 0.3, y = pos.y + 0.8, z = pos.z - 0.3},
            maxpos = {x = pos.x + 0.3, y = pos.y + 1.2, z = pos.z + 0.3},
            minvel = {x = -0.5, y = 1.0, z = -0.5},
            maxvel = {x = 0.5, y = 2.5, z = 0.5},
            minacc = {x = 0, y = -4, z = 0},
            maxacc = {x = 0, y = -1, z = 0},
            minexptime = 0.4,
            maxexptime = 1.2,
            minsize = 0.8,
            maxsize = 1.6,
            glow = 10,
            texture = "magic_touch_spark.png",
        })
    end,
})

If you changed the greeting yours has your words in that one line instead. That is allowed โ€” the words are free.

If it broke ๐Ÿ”ง โ€” the game is asking you a question

What you seeThe game is askingWhat to do
ModRunError + a line number"I got lost on line N"A function needs its end. Count your bags.
expected ')' near 'end'"A bracket is still open from earlier"Find the ( that never got its )
attempt to call field 'get_player_name' (a nil value)"'who clicked' was empty โ€” there was nobody"That is what if clicker then is for. Check it is still there
attempt to concatenate a nil value"you told me to glue words onto something that isn't there"name must be spelled the same in all three places
Right-click places a block instead"are you touching the chime, or just pointing near it?"Aim at the chime itself. If it still places, empty your hand and right-click again
Message works, no sparkles"those are two separate machines"Look inside add_particlespawner โ€” is a dial 0? Is the texture name wrong?
Sparkles are invisible"I have no picture to wear"Is it magic_touch_spark.png, inside textures/, spelled exactly like the code says?
Nothing new in the inventory"did you restart at all?"๐Ÿง’ ask a grown-up to put it in the game, then look for the awake line./deploy.sh -r magic_touch, then look for the awake line
Panic button โ€” always works ./deploy.sh -r magic_touch โ€” repo copy back into the game, old copy saved in .backups/ first. Nothing can be lost.

What you learned today ๐Ÿ†

callback = code that waits instead of running right now
on_rightclick = the thing that makes it snap
function โ€ฆ end = a bag of instructions to run later
the five presents โ€” pos, node, clicker, itemstack, pointed_thing
.. = glue for words, and that is how your name got into the message
if clicker then = do not try to greet nobody
min / max = the game picks a random number between them, every time

Level 1 made a thing exist. Level 2 made a thing happen. That is a bigger step than it sounds like.

Level 3 ยท Numbers That Change How a Block Feels ๐ŸงŠ๐Ÿ‘ป๐ŸชŸ

Three blocks that are almost nothing to look at, and completely different to walk on.

The blockWhat it does to you
Slippery Rainbow Iceyou slide
Ghost Blockyou walk straight through it
Magic Looking Glassyou see through it, but you can't walk through it
Your one new word groups โ€” a bag of labels with numbers in it. The game reads the bag and decides how the block behaves.
Before you start All three blocks are already in the game. Steps 1โ€“4 are us reading every line. Steps 5 and 6 are yours โ€” you run the lab and you tune the numbers.
1

Three blocks, one file

Level 3 lives in mods/magic_terrain.

Grown-up types./deploy.sh -r magic_terrain
Look for this line in the log [magic_terrain] My three feeling-blocks are awake!
Open your inventory and search for Slippery โ€” all three are in there.
Three blocks in one mod is normal A mod is just a list of orders, and a list can have three things in it as easily as one.
2

Block 1: the bag of labels ๐ŸงŠ

core.register_node("magic_terrain:ice", {
    description = "Slippery Rainbow Ice",
    tiles = {"magic_terrain_ice.png"},
    groups = {slippery = 5},
})
Read the new line out loud "Groupsโ€ฆ open braceโ€ฆ slippery equals fiveโ€ฆ close brace."
We never wrote how slippery No friction, no speed, no shoes, nothing. We put a label in a bag and wrote a number next to it โ€” and the game decides what slippery means, because the game invented that word. We are not telling the computer what to do. We are filling in a form the game already knows how to read.

Why a bag instead of one line? Because you can put lots of labels in the same bag:

    groups = {slippery = 5, cracky = 2},

That block is slippery and breakable with a pick. Level 1 had one number doing one job. A groups bag is how you give a block a whole personality without writing any real instructions.

The game uses the same labels

This is not our made-up list โ€” the game's own ice is:

    groups = {cracky = 3, cools_lava = 1, slippery = 3},

So our ice is slippery = 5 and the game's own ice is slippery = 3. Go and walk on both. Which slides more? That is a lab question, not a code question โ€” only you can tell us.

LabelWhat it tells the game
slipperyyou slide on it
crackya pickaxe breaks it
crumblya shovel breaks it
choppyan axe breaks it
snappyshears cut it
immortalnothing breaks it
3

Block 2: the yes / no switch ๐Ÿ‘ป

core.register_node("magic_terrain:ghost", {
    description = "Ghost Block",
    tiles = {"magic_terrain_ghost.png"},
    walkable = false,
})
New idea hiding in one word: false Some questions have exactly two answers. The computer writes them as true and false.
trueyes
falseno
Read it out loud walkable = false โ†’ "Can you walk on this? No."
That is the whole block. One switch, flipped the wrong way on purpose. You walk straight through it like it is made of smoke.

Notice there is no bag here. This one is a single switch sitting on its own. Some things go in the groups bag; some things are one line of their own.

A trap worth knowing now false without quotes is the yes/no answer. "false" with quotes is the word. Those are not the same thing, and the computer never guesses which one you meant.
4

Block 3: how the block gets DRAWN ๐ŸชŸ

core.register_node("magic_terrain:glass", {
    description = "Magic Looking Glass",
    tiles = {"magic_terrain_glass.png"},
    drawtype = "glasslike",
    use_texture_alpha = "blend",
})

Two new lines, and they are about something different entirely: not how the block behaves, but how the game draws it.

drawtype โ€” the style the game paints it in

glasslike "draw this one the way you draw glass" โ€” we are not telling the game to draw anything. We are pointing at a style the game already has and saying that one. Flat, all faces treated the same, light goes through it.

use_texture_alpha โ€” please actually show the see-through bits

A picture can have see-through dots in it. That's what "alpha" means: how see-through each dot is. But by default the game throws the see-through parts away and treats your picture as solid.

use_texture_alpha = "blend"
        โ†“
"some of my dots are see-through โ€” really show that, don't throw it away"
Without that line your beautiful glass becomes a solid brick. And our glass really is see-through: every single one of its 256 dots is partly see-through (most at 60 out of 255 โ€” a light frosted-glass fog).
Read both lines out loud "Draw typeโ€ฆ glass like. Use texture alphaโ€ฆ blend." โ†’ "Draw me like glass, and really show my see-through dots."
5

The lab ๐Ÿงช

You are going to guess first, then test. That order is the whole method.

Grown-up builds this on flat ground Course 1 โ€” three bridges: three bridges side by side, one block wide, three blocks above the ground. One of each block: ice, ghost, glass.
Course 2 โ€” the doorway: a wall with two doorways. A ghost block in one, a glass block in the other.
The rule of the lab Say your guess out loud before you test. A guess that turns out wrong is the best thing that can happen โ€” it means you just learned something you did not already know.
QuestionGuess out loudThen test
Which bridge do you slide off?
Can you walk through the glass doorway?
Can you walk through the ghost doorway?
Can you see through the floor of the ghost bridge?
Can you stand inside a ghost block?
Then tell us what surprised you That is the only part of this level nobody else can report.
6

Yours: tune the feelings ๐ŸŽ›๏ธ

One dial at a time. Deploy. Test. Then the next.

The slippery number. Try 1. Then 3 โ€” the game's own ice. Then 99. Does 99 slide more than 5, or is 5 already as slidey as it gets? Nobody told the computer what the biggest number is. Go find out.

The walkable switch. Change false to true. Walk on the ghost. What changed? Change it back.

The see-through line. Delete this whole line from the glass and redeploy:

    use_texture_alpha = "blend",

Go look at your glass. That is what it looks like when the game throws your see-through dots away. Then put the line back, deploy again, and watch the glass come back.

The most important experiment in this level You took a line out and watched what was missing. That is how grown-up programmers find bugs โ€” not by adding, but by removing one thing and watching what stops.
Before you stop Put the line back. And if anything is still weird, the panic button is one line long and always works.

Your whole file

This is exactly what is in your mods/magic_terrain/init.lua right now:

-- Three blocks that FEEL completely different.
print("[magic_terrain] My three feeling-blocks are awake!")

-- 1. SLIPPERY - you slide off it.
core.register_node("magic_terrain:ice", {
    description = "Slippery Rainbow Ice",
    tiles = {"magic_terrain_ice.png"},
    groups = {slippery = 5},
})

-- 2. GHOST - you walk straight through it.
core.register_node("magic_terrain:ghost", {
    description = "Ghost Block",
    tiles = {"magic_terrain_ghost.png"},
    walkable = false,
})

-- 3. GLASS - you can see right through it, but you cannot walk through it.
core.register_node("magic_terrain:glass", {
    description = "Magic Looking Glass",
    tiles = {"magic_terrain_glass.png"},
    drawtype = "glasslike",
    use_texture_alpha = "blend",
})

If it broke ๐Ÿ”ง โ€” the game is asking you a question

What you seeThe game is askingWhat to do
ModRunError + a line number"I got lost on line N"Count braces โ€” a { needs its }
Only one block in the inventory"I only got as far as the first one"Find the error line; the blocks below it never got registered
The glass is a solid opaque brick"you told me to throw the see-through away"Put use_texture_alpha = "blend" back
You fall through the glass"you set walkable = false on the wrong block"Only the ghost should have walkable = false
You cannot find the ghost block"it is mostly see-through, on purpose"Place it against a wall, or find it with your crosshair
The ice is not slippery"are you walking on it?"Slippery only shows when you walk and try to stop or turn
Purple / checkered block"which picture did you mean?"Check magic_terrain_ice.png etc. inside textures/
attempt to index โ€ฆ nil"I have never heard of that name"Check the spelling of groups, walkable, drawtype
Panic button โ€” always works ./deploy.sh -r magic_terrain โ€” repo copy back into the game, old copy saved first. Nothing can be lost.

What you learned today ๐Ÿ†

groups = a bag of labels with numbers, and the game decides what they mean
You do not have to know how slippery works to make something slippery
true / false = the computer's yes and no, and no quotes this time
drawtype = pick a drawing style the game already has
use_texture_alpha = "really show my see-through dots"
The lab method: guess out loud first, then test, then report what surprised you
The removal method: take one line out and see what goes missing

Level 4 ยท Things You Hold, Not Things You Place โญ

A Star Wand. You swing it at any block and that block turns into a glowing Star-Painted Block.

Your one new pair of words item and node โ€” and the difference between them.
Before you start The wand is already in the game. Steps 1โ€“5 are us reading every line. Step 6 is yours. This level has one big idea and then lots of small ones โ€” the big idea is worth slowing down for.
1

One file, two very different kinds of thing

Grown-up types./deploy.sh -r magic_wand
Look for this line in the log [magic_wand] My star wand is awake!

Open the file and look at the two big blocks inside it:

core.register_node("magic_wand:painted", {   -- โ† one kind of thing
...

core.register_tool("magic_wand:star", {      -- โ† a DIFFERENT kind of thing
Different words register_node and register_tool. That difference is the whole level. Everything else is small.
2

The paint (you can read this all by yourself)

-- The paint. A block the wand can turn other blocks into.
core.register_node("magic_wand:painted", {
    description = "Star-Painted Block",
    tiles = {"magic_wand_painted.png"},
    light_source = 8,
})
There is not one new word here โ€” read it out loud, alone "Computer, make a new block. Its real name is magic wand colon painted. The name people read is Star-Painted Block. Its skin is magic_wand_painted.png. It glows at 8. That is all the things. Go."

If that was easy, that is the point Level 1 taught you to read it.

3

A node is a PLACE. An item is a THING. ๐Ÿง 

This is the big idea. Read this table out loud.

nodeitem
what it isa place in the worlda thing you carry
the verbyou place ityou hold it
made bycore.register_nodecore.register_tool
in our modmagic_wand:paintedmagic_wand:star
where it livesin the ground, the wall, the skyin your bag, or your hand
one you already knowmagic:rainbow from Level 1this is your first item
Say it until it sticks "A node has a position. An item has a hand."

Your Level 1 rainbow block is a node. It sits exactly where you put it, with an x, y, z forever. The wand is an item. It has no position at all โ€” it is wherever you are. You cannot "place" a wand in the world the way you place a block. It lives in a hand or in a bag.

Why this matters for the rest of the tutorial A door is an item question ("what are you holding?"). A portal is a node question ("where are you standing?"). Level 8 is going to ask you both, and this is the level where you learn to tell them apart.
4

Two pictures: the bag picture and the hand picture ๐Ÿ–ผ๏ธ

core.register_tool("magic_wand:star", {
    description = "Star Wand",
    inventory_image = "magic_wand_star.png",
    wield_image = "magic_wand_star.png",

Two picture lines, because you look at a bag differently than you look at your own hand.

LineWhere you see it
inventory_imagethe small square in your bag
wield_imagethe big one in your hand, right in front of your eyes

Ours is the same picture both times โ€” but it does not have to be. You could draw a tiny neat star for the bag and a big sparkly one for the hand.

Later, when the art looks wrong If the hand version looks too big, cut off or blurry, that is wield_image you need to fix, not inventory_image. Two different problems, two different lines.
5

The swing: a waiting spell you already know ๐ŸŽ’

Level 2Level 4
the bagon_rightclick = function(โ€ฆ)on_use = function(โ€ฆ)
what makes it snapyou right-click the blockyou swing the item
who is insideclickeruser

This is not a new idea. Same idea, different trigger. In Level 2 the block waited for a touch. In Level 4 the wand waits for a swing.

    on_use = function(itemstack, user, pointed_thing)

Only three presents this time, not five โ€” an item does not need as many. And pointed_thing came all the way from Level 2. Same present, same name: what the crosshair is pointing at.

The guard at the door

        if not user then
            return
        end
Read out loud "If there is no person using this โ€” stop."
notthe opposite of. not user means "there is no user".
return"stop right here, do not do the rest of the bag."

return is the emergency exit out of the bag. Everything below it never happens.

6

The crosshair question: aiming or sky? ๐ŸŽฏ

        if pointed_thing.type ~= "node" then
            core.chat_send_player(name, "Aim the wand AT a block, not at the sky!")
            return
        end
Read it out loud as a sentence "If the thing my crosshair is on is NOT the same as a node โ€” tell them to aim at a block, and stop."

.type = "what kind of thing is this?" When your crosshair is on a real block the kind is "node". When it is on nothing, it is not "node".

SymbolMeans
=is the same as
~=is not the same as
The ~ is the tilde On your keyboard it sits next to the 1. A little squiggle that means "opposite of equal". Easy to mix up with = โ€” and when you do, the wand either paints everything or nothing at all.
Why ask at all? Because swinging the wand at the sky would try to paint nothing, and nothing has no position to paint. Instead the wand tells you what you did wrong, in words. A good machine tells you what it needed. That answer is a choice somebody made while writing it โ€” being kind to the person using your machine.
7

Changing the world, not just making things exist ๐ŸŒ

        core.set_node(pointed_thing.under, {name = "magic_wand:painted"})
Stop and look at how big this is Everything you have ever written made a thing exist. register_node, register_tool โ€” you were adding to the game's lists. You never touched the world. This line changes a block that is already out there into a different block.
BitWhat it means
core.set_node("change what is at this position"
pointed_thing.under"the block you are pointing at"
{name = "magic_wand:painted"}"become this"
Read the whole line out loud "Set the node at the block I am pointing at to be Star-Painted Block."
   your crosshair
        +
        |  โ† pointed_thing.under  (the solid block you aimed at) โ† THIS one changes
Grown-up types./deploy.sh -r magic_wand
In the game 1. find Star Wand   2. hold it   3. point at any block โ€” a tree, a wall, the ground   4. click   5. that block is now a glowing star-painted block โœ…
Whether the wand swings, whether the block changes, whether the "aim at a block" message shows when you point at the sky โ€” only you can see any of that.

Play with it ๐ŸŽฎ

Paint a path across a field โ€” a glowing road is one afternoon of clicking. Paint a picture on the side of a hill: painted blocks are pixels and the hill is the canvas. Paint a whole tree and stand back โ€” it glows at light_source = 8. Paint at night and see how far the glow reaches.

Ask before you paint anybody else's house That rule has nothing to do with computers and everything to do with not being the person who ruins a friend's castle.

Your whole file

This is exactly what is in your mods/magic_wand/init.lua right now:

-- A thing you HOLD, not a thing you place.
print("[magic_wand] My star wand is awake!")

-- The paint. A block the wand can turn other blocks into.
core.register_node("magic_wand:painted", {
    description = "Star-Painted Block",
    tiles = {"magic_wand_painted.png"},
    light_source = 8,
})

-- The wand itself.
core.register_tool("magic_wand:star", {
    description = "Star Wand",
    inventory_image = "magic_wand_star.png",
    wield_image = "magic_wand_star.png",
    on_use = function(itemstack, user, pointed_thing)
        if not user then
            return
        end
        local name = user:get_player_name()
        if pointed_thing.type ~= "node" then
            core.chat_send_player(name, "Aim the wand AT a block, not at the sky!")
            return
        end
        core.set_node(pointed_thing.under, {name = "magic_wand:painted"})
        core.chat_send_player(name, "Painted one block.")
    end,
})

If it broke ๐Ÿ”ง โ€” the game is asking you a question

What you seeThe game is askingWhat to do
ModRunError + a line number"I got lost on line N"Count brackets โ€” every ( needs its )
"Aim the wand AT a block" when you were aiming at a block"was your crosshair on empty space?"Aim at the middle of a face, not the edge or the corner
The block behind the one you aimed at changed"you hit the edge, so I used the block past it"Same fix โ€” aim at the middle of the block's face
Nothing happens at all"is the wand even in your hand?"Check you are holding Star Wand, not a block
"Aim at a block" forever, even pointing at dirt"is ~= actually ~=?"Check you have ~= and not = โ€” one character, whole different machine
attempt to index 'pointed_thing' (a nil value)"look at a thing that isn't there"Check the spelling of pointed_thing in every line
Painted block is purple"which picture did you mean?"magic_wand_painted.png inside textures/, spelled exactly like tiles says
Wand not in your inventory"did you restart at all?"๐Ÿง’ ask a grown-up to put it in the game, look for the awake line./deploy.sh -r magic_wand, look for the awake line
Panic button โ€” always works ./deploy.sh -r magic_wand โ€” repo copy back into the game, old one saved to .backups/ first. Nothing can be lost.

What you learned today ๐Ÿ†

A node is a place. An item is a thing. A node has a position; an item has a hand
core.register_node makes a block, core.register_tool makes a thing you hold
inventory_image = the bag picture, wield_image = the hand picture
on_use is Level 2's waiting spell with a different trigger
not = the opposite of, and return = stop right now
~= = not the same as (the squiggle means "opposite of equal")
core.set_node(โ€ฆ) = the first time your code changed the world

Level 1 made things exist. Level 2 made them answer. Level 3 made them feel. Level 4 put one of your things in your hand โ€” and let your code reach out and change the world.

Level 5 ยท Crafting: Things You Have to MAKE First ๐Ÿ”จ

The Rainbow Lantern โ€” except you are not allowed to just take it. A log becomes planks. Planks become sticks. One stick and four planks become a lantern that glows.

Your one new word recipe โ€” which is one new form with four blanks in it. That is all. Everything you fill a blank with, you can already read.
Before you start The crafting chain is already in the game: ./deploy.sh -r magic_craft. Steps 1โ€“8 are us reading every line. Step 9 is yours.
1

A level with no new spells in it ๐Ÿงˆ

Look for this line in the log [magic_craft] My crafting chain is awake!

Here is something strange. Go and look at the whole file. There is not one function in it.

Levelwhat the code was
Level 1"make this thing exist"
Level 2"wait for a touch, then do these things"
Level 3"here is a bag of labels, behave accordingly"
Level 4"wait for a swing, then change the world"
Level 5"here is a form. Filling it in is the whole job."
Say it and let it sink in You are allowed to program by filling in a form. The crafting table already knows what to do โ€” you just tell it what goes in and what comes out.
-- Things you have to MAKE before you are allowed to have them.
print("[magic_craft] My crafting chain is awake!")
2

The shopping list: four things ๐Ÿ”

Level 5 registers exactly four things. All in one look:

-- The start of everything. The only thing you get for free.
core.register_node("magic_craft:log", {
...
-- Planks. Not on the free shelf - these have to be made.
core.register_node("magic_craft:plank", {
...
-- Not a block at all. A thing you carry that does nothing on its own.
core.register_craftitem("magic_craft:stick", {
...
-- The prize. It glows, and there is no way to take one.
core.register_node("magic_craft:lantern", {
...
Namewhat kind of thingfree in your creative bag?
magic_craft:loga node (Level 4!)โœ… yes โ€” the one free thing
magic_craft:planka node๐Ÿ”’ no
magic_craft:sticka craft item๐Ÿ”’ no
magic_craft:lanterna node that glows๐Ÿ”’ no
Only one of those four is free Everything else you have to make. That is the whole level, sitting right there in a table.
3

How the lock works: a label you already know ๐Ÿ”

Open the file and find this line:

    groups = {choppy = 2, not_in_creative_inventory = 1},
You already know this โ€” it is Level 3 groups = {...} is a bag of labels and the game reads the bag to decide how a thing behaves. Two labels in this bag:
Labelwhat it tells the game
choppy = 2"wood. An axe is the right tool for me." (The game's own apple tree uses choppy = 2 too.)
not_in_creative_inventory = 1"do not put me on the free shelf."

That second label is the lock on the door. Not new technology โ€” the same bag from Level 3 doing a new job. 121 files in the game itself use that exact label, which is why you can trust it.

Go and check that right now ๐Ÿ‘€ Open your creative inventory and look for Rainbow Plank. It will not be there. Do not panic and do not tell your grown-up it is broken โ€” that is the level. The plank is not missing, it is locked. Then look for Magic Wood Log: that one is there, because the log carries no lock label.
4

The form: core.register_craft ๐Ÿ“

core.register_craft({
    recipe = {
        {"magic_craft:log"},
    },
    output = "magic_craft:plank 4",
})
Read it out loud as a sentence "Computer. The recipe is: one magic craft log in one square. The output is: four rainbow planks."
The blankwhat it means
recipe = { ... }the shape you lay out on the crafting grid
a row {"a", "b"}one row of the grid, left to right
""an empty square โ€” and it has to stay empty
output = "name 4"what you get. The space and the 4 mean how many
Look hard at output = "magic_craft:plank 4" The 4 is inside the quotation marks, with a space before it. It is not output = "magic_craft:plank", 4. One space, inside the quotes โ€” that is where this line breaks, so look at it every time you change it.
5

Where you actually put it: the grid ๐ŸŸฆ

In creative mode your inventory already has a crafting grid built in:

        your grid (3 x 3)                the result
   +-----+-----+-----+             +-----------+
   |  1  |  2  |  3  |             |           |
   +-----+-----+-----+    ===>     |  shows    |
   |  4  |  5  |  6  |             |  HERE     |
   +-----+-----+-----+             +-----------+
   |  7  |  8  |  9  |
   +-----+-----+-----+

Nine squares in. One square out. Drag things into the nine, and if they make a shape that matches a recipe, the thing you made appears on the right. Click it and it comes into your bag.

Your first craft ๐ŸŽ‰ Put one Magic Wood Log anywhere in the grid. The result fills with 4 Rainbow Planks. Take them.
Now the interesting part Put the log in the middle. Then the corner. Then the bottom-left. Same result every time. Guess why: the shape is one square, and one square fits anywhere. Keep that thought โ€” Step 6 is about shapes that do not fit everywhere.
6

The shape matters: two planks STACKED ๐Ÿ“š

core.register_craft({
    recipe = {
        {"magic_craft:plank"},
        {"magic_craft:plank"},
    },
    output = "magic_craft:stick 4",
})

Look at the shape. Two rows. One square wide. Stacked. Now guess before you test. Nobody learns anything from guessing after.

What you put in the gridYour guessWhat actually happened
two planks, one above the other?
two planks, side by side?
one plank only?
three planks stacked?

The reason side-by-side can fail: the recipe says stacked. The game does not turn your shape around to be helpful. It looks for the shape exactly as written.

And here is the good part If you want side-by-side to work too, you can make it work โ€” by writing a second recipe. Two recipes, same output, two shapes. Whether to allow that is not a computer question, it is a you question:
core.register_craft({
    recipe = {
        {"magic_craft:plank", "magic_craft:plank"},
    },
    output = "magic_craft:stick 4",
})
7

The lantern: a shape with holes in it ๐Ÿฎ

The last recipe, and the one you actually care about:

core.register_craft({
    recipe = {
        {"magic_craft:plank", "", "magic_craft:plank"},
        {"", "magic_craft:stick", ""},
        {"magic_craft:plank", "", "magic_craft:plank"},
    },
    output = "magic_craft:lantern",
})
   +-----+-----+-----+
   | p   |     | p   |     p = plank
   +-----+-----+-----+     . = empty (the "" you type)
   |     | s   |     |     s = stick
   +-----+-----+-----+
        an X
Now you know what "" is for It means "this square must be empty". It is not a gap you left because you were lazy โ€” it is you telling the game the middle of each edge stays empty. Take the "" out and the row only has two squares, so the shape becomes something else entirely and nothing gets crafted.

Notice four planks and one stick. A recipe can ask for more than one kind of thing.

8

Make the lantern for real (the counting part) ๐Ÿงฎ

   [log]  --recipe 1-->  4 planks
              1 log
   2 planks  --recipe 2-->  4 sticks

   4 planks  +  1 stick  --recipe 3-->  THE LANTERN
The trick that makes this a puzzle, not a chore A lantern wants 4 planks and 1 stick. But you cannot get a stick without spending 2 planks. So one lantern really costs 4 + 2 = 6 planks โ€” and 6 planks is one and a half logs. Which means: grab two logs. Not one. Two.
In the game, in order 1. Take two Magic Wood Logs   2. One log โ†’ take the 4 planks   3. Second log โ†’ 4 more planks (8 total)   4. Stack 2 planks โ†’ take the 4 sticks   5. Lay the X: 4 planks in the corners, 1 stick dead centre   6. Lantern. ๐Ÿฎ Take it, place it, it glows.
You should have 2 planks and 3 sticks left over. That is correct, not a mistake.
Your challenge, out loud How many logs does it take to make three lanterns? Guess, then go make three and find out. Answer at the bottom of the page โ€” but only after you have counted.
9

Now it is yours ๐Ÿ”ง

Grown-up types one change at a time, then ./deploy.sh -r magic_craft
ChangeToWhat happens
how generous a log isoutput = "magic_craft:plank 8",one log, eight planks โ€” your whole chain just got twice as easy
how bright the lantern islight_source = 14,12 is bright; 14 is the brightest the game allows. Stand next to it at night
break a shape on purposeturn the X sideways, stick in a cornerthe result square stays empty โ€” now you have seen a failed lookup
Do not change the names magic_craft:plank has to be spelled exactly the same in the recipe as in the registration. The recipe looks things up by name, and a wrong name is a lookup that can never succeed โ€” it will not even tell you, it will just never craft.

Your whole file

This is exactly what is in your mods/magic_craft/init.lua right now:

-- Things you have to MAKE before you are allowed to have them.
print("[magic_craft] My crafting chain is awake!")

-- ========== THE FOUR THINGS ==========

-- The start of everything. The only thing you get for free.
core.register_node("magic_craft:log", {
    description = "Magic Wood Log",
    tiles = {"magic_craft_log.png"},
    groups = {choppy = 2},
})

-- Planks. Not on the free shelf - these have to be made.
core.register_node("magic_craft:plank", {
    description = "Rainbow Plank",
    tiles = {"magic_craft_plank.png"},
    groups = {choppy = 2, not_in_creative_inventory = 1},
})

-- Not a block at all. A thing you carry that does nothing on its own.
core.register_craftitem("magic_craft:stick", {
    description = "Rainbow Stick",
    inventory_image = "magic_craft_stick.png",
    groups = {not_in_creative_inventory = 1},
})

-- The prize. It glows, and there is no way to take one.
core.register_node("magic_craft:lantern", {
    description = "Rainbow Lantern",
    tiles = {"magic_craft_lantern.png"},
    light_source = 12,
    groups = {choppy = 2, not_in_creative_inventory = 1},
})

-- ========== THE THREE RECIPES ==========

-- One log, anywhere on the grid, becomes four planks.
core.register_craft({
    recipe = {
        {"magic_craft:log"},
    },
    output = "magic_craft:plank 4",
})

-- Two planks STACKED, one on top of the other, become four sticks.
core.register_craft({
    recipe = {
        {"magic_craft:plank"},
        {"magic_craft:plank"},
    },
    output = "magic_craft:stick 4",
})

-- Four planks in the corners and one stick in the middle makes a lantern.
core.register_craft({
    recipe = {
        {"magic_craft:plank", "", "magic_craft:plank"},
        {"", "magic_craft:stick", ""},
        {"magic_craft:plank", "", "magic_craft:plank"},
    },
    output = "magic_craft:lantern",
})

If it broke ๐Ÿ”ง โ€” the game is asking you a question

What you seeThe game is askingWhat to do
The result square stays empty"is your shape exactly the shape?"Same rows, same order, empty squares kept empty
Empty, but the shape looks right"is it turned around or upside down?"Luanti does not rotate your shape. Put it the way the recipe is written
Empty, shape looks perfect"is there an empty square you filled?"The "" squares must be empty in the grid too
ModRunError + a line number"I got lost on line N"Count brackets โ€” every { needs its }
output gives you 1 instead of 4"where is the number?"output = "magic_craft:plank 4" โ€” space then number, inside the quotes
Nothing crafts, nothing looks wrong"did you spell the name the same in both places?"The name in the recipe must match the registered name character for character
You found a lantern in your creative bag"wait โ€” you should NOT be able to do that"not_in_creative_inventory = 1 is missing or misspelled. That label is the whole lock
A block is purple / unknown"which picture did you mean?"magic_craft_log.png, _plank, _stick, _lantern in textures/, spelled exactly like tiles / inventory_image says
The lantern does not glow"how bright did you set it?"light_source = 12 (0 = dark, 14 = brightest)
Not even awake"did you restart at all?"๐Ÿง’ ask a grown-up to put it in the game, look for the awake line./deploy.sh -r magic_craft, look for the awake line
Panic button โ€” always works ./deploy.sh -r magic_craft โ€” repo copy back into the game, the old one was saved to .backups/ first. Nothing can be lost.
One thing crafting really does cost The things you put in the grid get used up. Not a bug either โ€” if crafting did not use things up, making a lantern would not mean anything.

What you learned today ๐Ÿ†

recipe = one new form with four blanks. Filling it in is the whole job
core.register_craft does not wait for anything and runs no code โ€” it just adds an entry to the crafting table's list
recipe = { {"a"}, {"a"} } is a shape: rows and squares
"" = an empty square that must stay empty
output = "magic_craft:plank 4" โ€” the count lives inside the quotes
The shape must match exactly. No rotating. No helping you out.
A one-square shape fits anywhere in the 3ร—3; a big shape has to be right
The lock on the free shelf is a Level 3 label: not_in_creative_inventory = 1
You made something you could not get any other way โ€” and you decided how hard that was

Levels 1 to 4 were all "make a thing exist". Level 5 is the first level where you wrote down how things turn into other things. That is the beginning of systems.

Challenge answer: three lanterns take four logs. The leftovers from each lantern are not enough to start the next one, so the last log is the one that finishes the job. Counting leftovers is a real programming skill โ€” half of debugging is knowing where your things went.

The road ahead ๐Ÿ—บ๏ธ

Every level teaches one new word and makes one new thing you can see. Levels 1โ†’2โ†’3โ†’4 build on each other, so do those before jumping ahead.

1

The Magic Rainbow Block โœ…

You made: a block that never existed before. You named it, drew it, placed it, made it glow.
New word: register

2

The block answers when you touch it โœ…

You made: the Answering Chime โ€” right-click it and it greets you by name and puffs sparkles out of the top.
New word: callback

3

Numbers that change how a thing feels โœ…

You made: three blocks โ€” Slippery Rainbow Ice, Ghost Block (walk straight through) and Magic Looking Glass (see through, but not walk through).
New word: groups โ€” a bag of labels with numbers in it. cracky = 3 means "this breaks with a pick, at speed 3". slippery = 5 means "you slide off". The game reads the bag and decides how the block behaves.

This is where you stop typing words and start tuning.

4

Things you hold, not things you place โœ…

You made: the Star Wand โ€” swing it at a block and it turns into a glowing Star-Painted Block.
New word: item vs node A node is a place in the world. An item is a thing you carry. Your rainbow block is a node. Your wand is an item. Same idea, different verbs.

5

Crafting: things you have to make first โœ…

You made: the Rainbow Lantern โ€” out of a log, through planks and sticks, using three recipes. You cannot take one from the creative bag. That was the point.
New word: recipe โ€” one new form with four blanks. recipe = { ... } is the shape on the grid, output = "name 4" is what you get, and "" is a square that must stay empty.

This is design, not computer rules The first level where the game gets harder on purpose: you cannot get the cool thing until you make the boring thing first. You decided that.

6

Armour you can wear ๐Ÿ›ก๏ธ

You will: make a rainbow helmet, chestplate, leggings and boots โ€” and when you put them on you can see them on your own character. And they really protect you. Different armour stops different damage.

New words: armor_groups and armor_use armor_groups = what this stops, and how much. armor_use = how many hits before it breaks.
The best art trick in this tutorial You do not draw the armour from nothing. We take the game's own armour drawings as a template, copy them into our mod, and recolour them in Pixelorama. Same shapes that already fit the character perfectly โ€” your colours.
Sizes are not all the same (this trips up adults) inventory icon = 16ร—16 ยท the piece drawn on the body = 64ร—32 ยท the pretty preview = 32ร—64.
7

A brand new material with a personality

You will: invent a material โ€” say stormsteel โ€” that has to be made a special way, is hard to dig, does not burn, is heavy to carry, and makes good armour against lightning but bad armour against fire.

New word: properties One material, six different numbers, and suddenly it has a personality. This is where you stop asking "can I do this?" and start asking "what should this thing be?"

Why it comes later It is really Levels 3 + 5 + 6 holding hands.

8

Portals ๐ŸŒ€

8.1 โ€” one block in, one block out. Step into a rainbow block here โ†’ you are somewhere else. No animation, no fuss. Just there instead of here. New word: teleport, plus the idea of remembering where the other end is.

8.2 โ€” a real door: 4 wide, 5 tall. You build the frame out of rainbow blocks and the inside becomes the portal. Now the game has to understand a shape, not one block. This is where you learn to think in coordinates: is the player inside the frame, or beside it?

8.3 โ€” a locked door. The portal does nothing unless you are holding the right thing. Now your portal has a rule, not just a place. Two doors, two keys, two worlds.

8.4 โ€” the door remembers. After the server restarts, your portals still work. New word: save โ€” most things your mod makes are forgotten at restart, so learning what to write down and where is the difference between a toy and a world.

9

Your mod can talk to you

You will: type /magic in the chat and your mod answers โ€” which blocks you made, where they are, how to use them.

New word: chatcommand You are adding a command to the game itself. That is the same kind of thing /help is.

The order, out loud

1  a block exists                      โœ… done
2  it answers when you touch it        โœ… done
3  numbers change how it feels         โœ… done
4  things you hold instead of place    โœ… done
5  crafting โ€” make it before you get it  โœ… done
6  armour you can see on yourself
7  a whole new material with a personality
8  portals  (one block โ†’ a real door โ†’ locked โ†’ remembers)
9  your mod answers /magic

One new word. One new thing you can see. Then stop and play with it. That is the whole method.