LEARN TO CODE

Scriptlands teaches real Python, one piece at a time. Each piece is unlocked by crafting a chip, and each one makes a new kind of machine worth building, so there's always a reason to learn the next thing.

HOW THE GAME TEACHES

01

A fix, not a blank page

Starter turtle lessons introduce commands with working examples. The optional ruin gives you a broken machine to repair, and the in-game Reference explains each machine’s commands.

02

Errors in plain words

Every error names the line and says what to do: "grind isn't defined. Did you mean grind()?" Misspellings get a suggestion.

03

Watch it run

Step runs a script one line at a time and lights up each line, so you can see a loop go round.

04

Only what you've unlocked

The token bar and suggestions offer only the syntax you have. Locked words show crossed out, with the chip that opens them.

05

A budget that teaches

Each run has a number of operations to spend. Wasteful scripts run out, which makes loops, functions and events feel like real tools, not chores.

06

Code is never a wall

Every system has a no-code option first: a lever lights a lamp, a quarry has settings. Code is how you go further.

THE LESSONS, TIER BY TIER

Every example below runs in the game as written.

T0Punch Card

Calling functions

A script is a list of commands that run in order. Each line calls one of the machine's functions, and some take a value in brackets: which side to pull from or push to.

  • Functions and their arguments
  • Running in order, top to bottom
  • Comments with #
MACERATOR
# A Macerator's first script
pull(BACK)
grind()
push(FRONT)
T1Register

Variables

Give a value a name and use it later. Numbers, text, and the answers functions give back. A machine remembers its variables between runs, so it can keep count.

  • Assignment with =
  • Numbers, text and arithmetic
  • print() to the machine's console
ANY MACHINE
# Text and numbers
left = energy()
print("energy left:", left)
half = left / 2
print("half of it:", half)
T2Logic Gate

Decisions

Machines start making choices: send ore one way and coal another, burn fuel only when the battery is low. This is where sorting and fuel checks come from.

  • if, elif, else
  • Comparisons: == < >
  • and, or, not
DIAMOND PIPE
# A Diamond Pipe that sorts
item = pull()
if item.tag == "ore":
    push(LEFT)
elif item.name == "coal":
    push(FRONT)
else:
    push(RIGHT)
T3Loop Coil

Loops

One run can repeat work. A turtle digs a whole tunnel; a quarry digs a whole pit. Turtle actions wait for each move, so the loop reads exactly like what happens in the world.

  • for with range()
  • while, break, continue
TURTLE
# A turtle clears a path
for step in range(5):
    dig(FRONT)
    move(FRONT)
turn(BACK)
stop()
T4Subroutine

Functions of your own

Name a behaviour once and use it again with different values. Functions keep their names to themselves and hand back a result with return.

  • def and parameters
  • return values
  • Local names
TURTLE
def dig_row(length):
    for i in range(length):
        dig(FRONT)
        move(FRONT)
    return length

dug = dig_row(8)
print("dug", dug, "blocks")
stop()
T5Memory Bank

Lists and dicts

Hold many values at once: a recipe as rows of item names, or a dict of how many of each item to keep. The Programmable Crafter takes its recipes as lists.

  • Lists: [1, 2], items[0], append()
  • Dicts: {"coal": 3}, d["coal"]
  • in, len(), sorted()
PROGRAMMABLE CRAFTER
# Keep a stock of a few items
wanted = {"torch": 16, "stick": 8}
for name in wanted:
    if count(name) < wanted[name]:
        craft(recipe(name))
T6Signal Net

Events and messages

Machines on a data cable can talk. A script with handlers sets itself up once, then runs only when something happens: a message, an item arriving, a job done, power running low.

  • @on("message") handlers
  • send(), broadcast(), receive()
  • Events: message, tick, item_in, done, power_low
MACHINE 1 · SENDS
set_name("boss")
send("boiler", "pause")
MACHINE 2 · LISTENS
set_name("boiler")

@on("message")
def heard(msg):
    print(msg.sender, "says", msg.data)
> boss says pause
T7Class Forge

Classes and fleets

The top of the language. Make your own kinds of thing with their own values and methods. A class built on Bot becomes robot firmware: deploy() sends it to every robot with that name.

  • class, self, __init__
  • Methods and instance values
  • A base class
ANY MACHINE ON THE NETWORK
class Harvester(Bot):
    def __init__(self):
        self.dug = 0

    def tick(self):
        if self.dug < 6:
            self.dig(FRONT)
            self.move(FRONT)
            self.dug += 1

sent = deploy(Harvester, "miner")
print("deployed to", sent, "robots")
> deployed to 3 robots
Real Python

How it differs from Python

Scripts are a subset of Python 3, run by the game's own interpreter. What you learn carries straight over to Python on a computer. The differences are small and deliberate:

  • Syntax unlocks in tiers, as above.
  • No import. Machines share code by deploying classes.
  • No slices, tuples, unpacking or comprehensions (yet).
  • Whole numbers have a limit, and say so if you go past it.
  • Each run has an ops budget, so a loop that never ends stops cleanly.
  • Scripts can't touch files, the network or your computer: they only control the machine they're in.
A Macerator's screen with its script: pull BACK, grind, push FRONT, with the second line highlighted while it runs.

FOR PARENTS AND TEACHERS

Scriptlands is designed for players 12 and up who have never programmed, without talking down to players who have.

WHAT IT COVERS

The core of an introductory programming course, in order: functions, variables, conditions, loops, writing functions, lists and dicts, events, and classes. Each is introduced when a machine needs it.

SAFE BY DESIGN

No accounts, no chat with strangers unless a player hosts or joins a world, and no internet needed to play. Scripts can only control machines inside the game.

IN A CLASSROOM

Students can play on one hosted world over the school network. A classroom mode, where a teacher chooses which tiers are open, is planned. Lesson plans and worksheets will be posted here.