Skip to content

JavaScript API (api)

Available inside the microscripter Web Worker alongside Pilot-style globals. All calls are async-friendly where they hit the main thread via RPC.

Methods

api.log(...args)

Prints to the microscripter console panel (strings joined with spaces).

api.find(type?)

Returns connected parts as { id, type, label }[]. Pass a type string to filter (internal id, e.g. disk).

api.ship.fire()

If the assembly has gun parts, fires lasers from each. Otherwise applies a short thrust pulse on the assembly.

api.disk.read() / api.disk.write(text)

Legacy whole-disk string blob for the first attached disk (requires port + disk on the component).

api.modem.fetch(url, init)

Passes through to fetch; response text may be truncated in the handler. CORS rules apply.

api.pc.runP5(code)

Runs p5 in the PC panel (port + pc required).

api.pc.physics.*

addBox, step, snapshot, clear — 2D demo physics for the PC surface.

api.screen.draw(partId, ops)

ops is an array of { op: "clear"|"fillRect"|"disk", ... } for a connected Screen part.