Aliou Diallo

pi-playdate

Build, run, inspect, and deploy Playdate games in Lua and C from Pi.

banner

pi-playdate

A pi extension for developing Playdate games. Provides typed tools for building, running, inspecting, and deploying Playdate projects in Lua and C.

Install

pi install git:github.com/aliou/pi-playdate

Quick Start

> Create a new Playdate game called "Bounce" in Lua
# Agent reads the playdate skill, creates Source/main.lua and Source/pdxinfo

> Build and run it
# Agent calls playdate_build then playdate_run_sim

> Take a screenshot so I can see it
# Agent calls playdate_screenshot, returns the image

Tools

ToolDescription
playdate_doctorCheck SDK installation, pdc, simulator, ARM toolchain, device
playdate_buildCompile Lua or C project to .pdx bundle
playdate_build_releaseCompile Lua or C project to a release .pdx bundle (pdc -s for Lua)
playdate_run_simLaunch the Playdate Simulator
playdate_stop_simStop the running simulator
playdate_sim_logRead recent simulator output from process logs and DAP console/output events
playdate_screenshotCapture simulator screenshot (returned as image)
playdate_sim_inputSend D-pad/A/B/menu input to the simulator
playdate_sim_crankSet simulator crank angle and dock state
playdate_sim_accelSet simulator accelerometer values
playdate_sim_stateRead simulator hardware state (crank, accel, buttons, FPS, battery, time)
playdate_sim_game_stateCheck the __pi_state() convention and dump structured game state
playdate_sim_game_state_writeApply structured game state via __pi_state_write() using patch or replace
playdate_sim_evalEvaluate Lua expressions in the running simulator
playdate_device_logRead serial log output from a connected Playdate device
playdate_run_deviceDeploy .pdx to a connected Playdate
playdate_install_deviceBuild, deploy, and launch a Playdate project on device

Commands

CommandDescription
/playdate:doctorCheck environment health
/playdate:simBuild and run in simulator
/playdate:deviceBuild and deploy to device
/playdate:settingsConfigure SDK path, build mode, etc.

Settings

Stored at ~/.pi/agent/extensions/playdate.json (global) and .pi/extensions/playdate.json (project).

SettingDefaultDescription
sdkPath$PLAYDATE_SDK_PATHOverride SDK path
defaultTarget"simulator"Default build target
buildMode"debug"C build mode
armToolchainPathauto-detectARM toolchain for C device builds
autoOpenSimulatortrueAuto-open simulator after build
simulatorLogLines200Simulator log ring buffer size

Requirements

Runtime inspection and control

For common simulator loops, prefer the typed tools over generic eval:

Game code can expose a global __pi_state() function that returns a plain Lua table. Then playdate_sim_game_state verifies the convention and dumps that table.

Games that support state injection can also expose __pi_state_write(payload, mode). Then playdate_sim_game_state_write sends plain JSON-like data with mode = "patch" | "replace".

playdate_sim_log reads the shared in-memory log ring buffer fed by simulator stdout/stderr and DAP output events when available. Use it early in crash/debug loops.

playdate_sim_eval still supports:

Examples:

Skill

The extension ships a playdate skill with reference docs for the Lua API, C API, CoreLibs, project layout, templates, performance tips, and common patterns. The agent loads these on demand when working on Playdate projects.

Dev docs

These are implementation docs for extension contributors, not end-user usage docs: