Scripting Crash Course
You do not need to learn a whole programming language to automate a Minecraft base. Nearly every MPLC script uses the same six building blocks.
1. Top level vs. scan()
Section titled “1. Top level vs. scan()”Every MPLC script has two parts:
- Top level (outside
def scan():) — runs once when you upload the program. Put yourpoint(...)handles,register(...)memory slots, and fixed numbers here. def scan():— runs repeatedly on the PLC’s timer (every 20 ticks by default). Put your checks andmove(...)calls here, indented by 4 spaces.
CHEST_A = point("chest_a/item") # top level: set up onceCHEST_B = point("chest_b/item")
def scan(): # runs every scan move(CHEST_A, CHEST_B, 16)2. Points and move()
Section titled “2. Points and move()”A point is one interface plus one expansion card: point("name/kind").
| Card | Suffix | Example |
|---|---|---|
| Item Expansion / World Item Card | /item |
point("chest/item") |
| Fluid Expansion / World Fluid Card | /fluid |
point("tank/fluid") |
| Energy Expansion | /energy |
point("battery/energy") |
| Redstone Expansion | /redstone |
point("lever/redstone") |
| World Sensor | /world |
point("geode/world") |
Use move(source, destination, amount, key=...) to transfer resources between two points of the same kind:
move(CHEST_A, CHEST_B) # move anything, up to tier capmove(CHEST_A, CHEST_B, 8) # move at most 8 items of anythingmove(CHEST_A, CHEST_B, 8, key="minecraft:coal") # move at most 8 coalmove(CHEST_A, CHEST_B, key="#minecraft:logs") # move any kind of logNotice that key= is always written with key= in front of it. Energy has no keys, so energy moves only take an optional amount: move(GEN, BATTERY, 10000).
3. Item IDs and #tags
Section titled “3. Item IDs and #tags”Every item, fluid, and block in Minecraft has an ID like "minecraft:iron_ingot" or "minecraft:water".
If you want to match a whole category—like any wooden log, any plank, or any crystal cluster—put # in front of a tag:
"#minecraft:logs"matches oak logs, spruce logs, birch logs, and modded logs."#c:ores"matches ores across vanilla and mods."#c:clusters"matches full amethyst and GeOre clusters (not growing buds).
4. Making decisions with if
Section titled “4. Making decisions with if”Use if, elif (“else if”), and else to react to stock levels or redstone signals:
TANK = point("tank/fluid")ALARM = point("alarm/redstone")
def scan(): lava = TANK.count("minecraft:lava") if lava < 4000: ALARM.set(15) # turn lamp on when under 4 buckets else: ALARM.set(0) # turn lamp offCommon comparisons: < (less than), <= (less or equal), > (greater than), >= (greater or equal), == (equals), != (not equal), plus and, or, not.
5. Repeating over groups with for
Section titled “5. Repeating over groups with for”If you have several similar interfaces—like furnace_1, furnace_2, furnace_3—match them all with points("furnace_*/item") (with an s and a * wildcard) and loop through them with for:
SUPPLY = point("supply/item")FURNACES = points("furnace_*/item")
def scan(): for f in FURNACES: need = 8 - f.count("minecraft:coal") if need > 0: move(SUPPLY, f, need, key="minecraft:coal")When you add furnace_4 later, this script picks it up automatically without any edits.
6. Remembering things with register()
Section titled “6. Remembering things with register()”Normal variables inside scan() vanish when the scan finishes. When your PLC needs to remember something across scans—like whether a generator is currently turned on, or how many scans have passed—declare a register at the top level:
COUNT = register("count", 0)
def scan(): COUNT.set(COUNT.get() + 1) if COUNT.get() == 1: print("First scan at tick", now())- Use
COUNT.get()to read the saved value. - Use
COUNT.set(new_value)to update it. - The default value (
0,False,"",[0, 0], etc.) locks in the register’s type. Even if you break and move the PLC block, it keeps its saved register values.
One important rule: no while or sleep
Section titled “One important rule: no while or sleep”MPLC does not allow while loops or sleep(). Instead of waiting inside one scan, return and check again on the next scan—or use the built-in mplc:timers module for delays. See The Scan Cycle & Commits if you are curious why.
Next step
Section titled “Next step”Learn how to craft higher-tier hardware and manage FE power in Tiers, Upgrades & Power, or jump into the Cookbook for complete builds.
Not an official Minecraft website. Not approved by or associated with Mojang or Microsoft.