Built-in Functions
All built-in functions below are available globally without load().
point(ref)
Section titled “point(ref)”Returns a Point handle for one bound Interface expansion.
point(ref: string) -> Pointref—"interface_name/suffix". Both parts are required even if the Interface has only one card.- Resource suffixes:
item,fluid,energy - Control suffixes:
redstone,world
- Resource suffixes:
- Constructing the handle at top level does not read the world. The handle resolves by name on each scan; missing or duplicate bound interface names fault when used.
points(pattern)
Section titled “points(pattern)”Returns a Group matching all bound Interfaces whose names match a wildcard pattern.
points(pattern: string) -> Grouppattern—"name_pattern/suffix". The interface name part must contain at least one*; the suffix must be literal (no wildcard in the suffix).- Membership is fixed for the duration of one scan and sorted in natural name order (
furnace_2beforefurnace_10). - An empty group has zero stock and plans no moves (does not fault).
register(name, default)
Section titled “register(name, default)”Declares a persistent local Register saved on the PLC across scans, world reloads, and breaking/placing the block.
register(name: string, default: any) -> Register- Must be called directly at the main program’s top level (forbidden inside
load()modules or insidescan()). name— unique string identifier for this PLC.default— any non-Nonevalue (bool,int,float,string,list,tuple,set, ordict). Fixes the register’s outer type.- Uploading a new program with the same register name and type preserves its saved value even if
defaultchanged. Changing the type resets it to the new default; omitting the declaration deletes the register.
Register methods
Section titled “Register methods”reg.get()— returns the current value (immutable; includes any.set()staged earlier in the same scan).reg.set(value)— stages a replacement value matching the register’s declared type. Written at commit; discarded if the scan faults before commit.
hub(name)
Section titled “hub(name)”Returns a handle for a Hub that this PLC has joined on its cable segment.
hub(name: string) -> Hubname— exact lowercase hub name configured in the Hub screen.- Missing or ambiguous hub names fault when a register or channel on the hub is used.
- See Hubs & Standard Library for
.register()and.channel().
move(src, dst, n=None, *, key=None, **options)
Section titled “move(src, dst, n=None, *, key=None, **options)”Schedules a resource transfer at commit time and returns the planned amount (int).
move(src: Point | Group, dst: Point | Group, n: int | None = None, *, key: string | None = None, **options) -> intsrc,dst—PointorGroupof the same resource kind (item,fluid, orenergy).n(optional, positional or keyword) — maximum total amount to move (in items, mB, or FE). Omit to move as much as remaining transfer allowances permit. On aGroup,ncaps the whole call, not each member.key(keyword-only) — resource ID ("minecraft:coal") or#tag("#minecraft:logs"). Omit to consider any resource. Forbidden on keyless kinds (energy).**options(keyword-only) — destination card options:- World Item Card:
at=(x, y, z),mode="place"(default) ormode="drop". - World Fluid Card:
at=(x, y, z). - Unknown options fault and name the offending option.
- World Item Card:
- Return value: planned amount, not guaranteed delivered amount. Short deliveries at commit do not fault.
- Each planned move leg charges 80 steps plus I/O units.
load(module, *names, **aliases)
Section titled “load(module, *names, **aliases)”Imports public top-level symbols from a Programmer library module or a built-in mplc: module.
load("mplc:timers", "on_delay", "off_delay")load("my_lib", "TARGET", helper="top_up")- Must appear at the top of the file before other statements.
- Bare names (
"my_lib") load case-sensitive entries from the uploading Programmer’s library. mplc:names load built-in modules (currentlymplc:timers).- Names starting with
_are private and cannot be imported. Imported names are not re-exported by a module. Cycles are rejected.
Returns the current game tick (int).
now() -> int- Use
now()for elapsed time calculations (20 ticks = 1 second) rather than counting scans.
print(*args, sep=" ")
Section titled “print(*args, sep=" ")”Appends a formatted line to the PLC’s log (also displayed in Dry run results).
print(*args, sep: string = " ") -> Nonefail(*args, sep=" ")
Section titled “fail(*args, sep=" ")”Immediately aborts the current scan with an error message, discards all staged writes and moves, and places the PLC in Fault mode.
fail(*args, sep: string = " ") -> never- Use
returnfor normal idle/skip conditions; reservefail()for unexpected invariant violations you want surfaced on the PLC screen.
Not an official Minecraft website. Not approved by or associated with Mojang or Microsoft.