Slice 3: Player Peripheral #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CC Autoplay — Slice 3: Player Peripheral — Build Plan
Milestones
M1 — API/peripheral scaffolding
Goal: Establish the CC:T integration contract for the player computer.
playeras a built-in Lua API on the player computer (same model asturtle:ILuaAPIregistered viaComputer.addApi), not a peripheral.player_inventoryandplayer_hotbaras local peripherals by default viacomputer.getEnvironment().setPeripheral(ComputerSide, IPeripheral).player_inventoryonback,player_hotbaronbottom.peripheral.find("player_inventory")andperipheral.find("player_hotbar")are the stable lookup path; sides are deterministic forperipheral.wrap.computer.queueEvent).Done when: From Lua,
peripheral.find("player_inventory")/peripheral.find("player_hotbar")return the built-in peripherals,peripheral.wrap("back")/("bottom")work, and theplayerAPI is present.M2 — Player inventory and hotbar peripherals
Goal: Expose the player's own inventory/hotbar through standard CC inventory semantics.
player_inventory(27 main slots) andplayer_hotbar(9 slots) as CC inventory peripherals.size()list()getItemDetail(slot)getItemLimit(slot)pushItems(toName, fromSlot [, limit [, toSlot]])pullItems(fromName, fromSlot [, limit [, toSlot]])player_hotbar:select(slot),getSelectedSlot()getItemCount([slot])drop([count]),dropUp([count]),dropDown([count])place()transferTo(slot [, count])equipLeft(),equipRight()Done when: Lua can list/inspect player inventory and hotbar, move items between them and other attached inventory peripherals, select hotbar slots, and perform hotbar item actions.
M3 — Reach/sight snapshots and block selection
Goal: Provide a fair, sight-based world view for scripts.
turtle.inspect()data shape:namestatetagsDone when: Lua can get a current reach snapshot, identify a specific block, and use that selection for later interaction calls.
M4 — World actions and interacted container peripherals
Goal: Let scripts act on the world like a player, with normal constraints.
pushItems/pullItemsuse CC:T standard arg order:pushItems(toName, fromSlot [, limit [, toSlot]]),pullItems(fromName, fromSlot [, limit [, toSlot]]).Done when: A script can select a reachable chest/furnace/crafting table, interact to expose it, transfer/craft via the exposed peripheral, and close it normally.
M5 — Chat events and chat API
Goal: Expose chat as observable events and player-controlled outbound actions.
chat_messagechat_whisper(isServer: bool, who: string, what: string, verified: bool).isServer: easy server/system filter.who: sender username, or server/system identity as defined by implementation (not the literal string"server"unless explicitly chosen).what: message contents.verified: Minecraft message signature/validation flag; not required for feature use.chat.send(message)— send message as the player.chat.whisper(who, message)— send whisper command/message to a user.chat.*surface above (finalize as separatechatAPI orplayer-adjacent API during M1/M5 implementation; default plan assumeschatAPI).Done when: Lua can receive chat events, filter server/user messages, send chat, and whisper.
M6 — Movement and dirty map
Goal: Provide fair movement primitives and planner-based navigation.
Done when: Lua can steer the player directly, request a go-to plan over known map data, execute/interrupt it, and handle step failures.
M7 — Vision extras and glasses overlay
Goal: Add richer perception and AR overlay, without giving unfair sensing.
playerAPI (GPS-style convenience must not imply modem/GPS host behavior unless explicitly implemented).canvas()(2D) andcanvas3d()(3D)Done when: Lua can read look/position, perform fair visible scans, and draw AR markers tied to script-known data.
Goal
Expose the local player to ComputerCraft Lua so scripts can automate player actions: inventory management, movement, world interaction, and chat. Client-side only, Fabric, Minecraft 26.1/26.3 target as repo currently configured, CC:Tweaked 1.121.0.
Fairness principle (load-bearing)
The code drives the player, but the player stays bound by human limits:
Baritone is the line not to cross. Baritone decides and executes with full world knowledge — it reads chunk data, knows every block, and auto-pathfinds with complete information. You may look at Baritone to understand how it works. Do not reimplement it. Our approach is sight-based (a map built from what the player actually saw) and the script stays in control.
Naming and Lua surface
player— final name. Lua API, liketurtle; not a peripheral. It is the main player contract.player_inventory— final name. Auto-attached peripheral. Side:back.player_hotbar— final name. Auto-attached peripheral. Side:bottom.chat— outbound chat namespace/API (chat.send,chat.whisper); finalize exact registration style during implementation, but keep thechat.*Lua shape.peripheral.find(...)as the primary contract. No modem peripheral is required.What already exists (do not rebuild)
muse-lantern/cc-autoplay, branchmain.PlayerComputer(real CC:TComputerrunning Cobalt Lua with CraftOS bios) with virtual filesystem./is per-server (.minecraft/cc-autoplay/servers/<hashed-server-ip>),/romis read-only CraftOS ROM,/.player/is shared across worlds. Terminal renders with CC:T'sFixedWidthFontRenderer. Custom inventory UI screen (271 wide: 17px sidebar + 254px texture), modeled on CC:T's turtle screen, with power/terminate buttons. Vanilla slot layout so normal slot-click packets work.cc-autoplayer(do not rename unprompted). License: not chosen (do not add one unprompted).Integration contract (CC:T 1.121.0)
PlayerComputerowns a coredan200.computercraft.core.computer.Computer.playerasILuaAPIviacomputer.addApi(...).IPeripheraland attach withcomputer.getEnvironment().setPeripheral(ComputerSide, IPeripheral).Environment(core) exposessetPeripheral/getPeripheral;IAPIEnvironmentdoes not exposesetPeripheral.Inventory
Two built-in peripherals. Both expose the standard CC inventory API:
player_inventory— main inventory (27 slots),back.player_hotbar— hotbar (9 slots),bottom.Standard methods:
size()— number of slots.list()— sparse table, slot number to{name, count, nbt}.getItemDetail(slot)— full detail: displayName, damage/maxDamage/durability, enchantments, etc.getItemLimit(slot)— max stack size for the slot.pushItems(toName, fromSlot [, limit [, toSlot]])— move items to another peripheral.pullItems(fromName, fromSlot [, limit [, toSlot]])— pull items from another peripheral.Arg order note: CC:T 1.121.0
AbstractInventoryMethodsconfirms the standard order above (toName/fromName, fromSlot, limit, toSlot).Hotbar turtle-style commands (on
player_hotbar):select(slot)— select a hotbar slot.drop([count])— drop the selected item.place()— place the selected block.dropUp([count]),dropDown([count])— drop upward/downward.transferTo(slot [, count])— move selected stack to another slot.getSelectedSlot()— currently selected hotbar slot.getItemCount([slot])— count of items in a slot.equipLeft(),equipRight()— equip the selected item to the left/right hand.Reach/sight and block interaction
turtle.inspect()data:namestatetagsWorld actions
All in reach (4.5 blocks). All take real time.
Chat
chat_message,chat_whisper.(isServer: bool, who: string, what: string, verified: bool).isServerallows quick filtering; sender identity provides a second check.verifiedis Minecraft signature/validation state; not required.chat.send(message)chat.whisper(who, message)Movement
Two modes. Both are in scope.
Directional steering
Direct control: turn, walk forward/backward, strafe, jump, sprint, sneak. The code steers; the player moves at normal speed.
Go-to-target
The script names a target position. The mod plans a route and returns it. Go-to is a planner, not an executor:
Open decision: go-to strategy
Not yet decided. Two options:
Do not pick one unilaterally — ask before building go-to.
Dirty map
A data storage feature: local per-server data holding a surface scan of the world.
Vision and glasses
playerAPI. Do not conflate with CC:Tgpsmodem host behavior unless explicitly implemented.canvas()andcanvas3d(); scripts draw text/rect/box/line/point primitives. Scope canvas object model when building M7.Out of scope for this slice
cc-autoplayerunprompted).Open questions (ask before building)
chatAPI orplayer-adjacent API? (Lua shapechat.send/chat.whisperis desired.)name/state/tags.Build context
main. Push to remotelanternonly, neverorigin.muse-lantern <lantern@example.com>.cd ~/workspace/cc-autoplay && JAVA_HOME=/home/lantern/jdk-25 xvfb-run -a ./gradlew runClient --no-daemon.onPresson buttons under xvfb. Button click-through can only be verified by Zach locally. Keyboard navigation works. Never claim clicks are verified.