The Scan Cycle & Commits
If you have used other Minecraft computer mods, you might expect a script to run forever in an infinite while True: loop with sleep(1) calls in the middle. MPLC works differently on purpose, following how real industrial PLCs operate.
Read → Decide → Commit
Section titled “Read → Decide → Commit”Every time a PLC’s scan timer fires, it goes through three clean phases:
- Check readiness: Verify the PLC has enough FE for its clock charge and that every Interface, Hub, and World Card box it depends on is connected and in a ticking chunk. If anything is missing, pause in Waiting without running the script.
- Run
scan()(staging): Your script reads inventories, checks redstone, updates registers, and schedules calls likemove(),set(),dig(), anduse(). Nothing changes in the world yet—instead, MPLC records your planned actions and updates its internal plan so latercount()calls in the same scan reflect what you already promised to move. - Commit: Once
scan()returns cleanly, MPLC applies everything in a fixed order:- Save local registers
- Save Hub registers
- Execute
move()transfers (including World Item/Fluid placements and drops) - Apply control outputs (Redstone
set(), World Sensordig()anduse()) - Notify neighboring blocks
Why staged commits help players
Section titled “Why staged commits help players”- Half-finished crashes cannot corrupt your base: If your script hits a bug or runs out of steps halfway through
scan(), every staged write and move is discarded. Nothing gets half-transferred or stuck halfway through an update. - No server-freezing infinite loops: Because
while, recursion, andsleep()do not exist in Starlark, a typo can never hang a multiplayer server or lock up a chunk. - Dry Run is exact: Because scans stage their intentions before touching the world, Dry run can execute the exact same scan against live inventories and show you the planned effects without changing a single item.
- No accidental duplication or invisible mid-scan hops: Items planned to arrive at chest
Bcannot be forwarded out ofBin the same scan. Wait until the next scan soBreally holds the items before moving them onward.
Why short deliveries are not faults
Section titled “Why short deliveries are not faults”Between planning a move() and actually inserting into a modded machine at commit time, another hopper, pipe, or player might fill a slot—or a machine might refuse a particular item variant.
When that happens, MPLC simply delivers whatever fits and leaves the rest safely in the source block (or returns it to the source’s input buffer). A short delivery never faults your PLC; your script checks real stock again on the next scan.
Not an official Minecraft website. Not approved by or associated with Mojang or Microsoft.