Comprehensive mapping of all ComputerCraft events and their parameter types

This interface provides type definitions for all built-in ComputerCraft events, enabling type-safe event handling in TypeScript. Each event is documented with its parameters and links to official ComputerCraft documentation.

async function handleMouseInput() {
const [button, x, y] = await os.pullEvent<Events["mouse_click"]>("mouse_click");
console.log(`Clicked at (${x}, ${y})`);
}
function onRednetMessage([sender, message, protocol]: Events["rednet_message"]) {
if (protocol === "myProtocol") {
// Handle protocol-specific message
}
}
interface Events {
    alarm: [id: number];
    char: [character: string];
    computer_command: string[];
    disk: [side: Side];
    disk_eject: [side: Side];
    file_transfer: [files: TransferredFiles];
    http_check: [url: string, success: boolean, error?: string];
    http_failure: [url: string, error: string, response?: HTTPResponse];
    http_success: [url: string, response: HTTPResponse];
    key: [key: number, hold: boolean];
    key_up: [key: number];
    modem_message: [
        side: Side,
        channel: number,
        replyChannel: number,
        message: unknown,
        distance?: number,
    ];
    monitor_resize: [side: Side];
    monitor_touch: [side: Side, x: number, y: number];
    mouse_click: [button: MouseButton, x: number, y: number];
    mouse_drag: [button: MouseButton, x: number, y: number];
    mouse_scroll: [direction: number, x: number, y: number];
    mouse_up: [button: MouseButton, x: number, y: number];
    paste: [text: string];
    peripheral: [side: Side];
    peripheral_detach: [side: Side];
    rednet_message: [id: number, message: unknown, protocol?: string];
    redstone: [];
    speaker_audio_empty: [side: Side];
    task_complete: [
        id: number,
        success: boolean,
        error?: string,
        ...args: unknown[],
    ];
    term_resize: [];
    terminate: [];
    timer: [id: number];
    turtle_inventory: [];
    websocket_closed: [url: string, reason?: string, code?: number];
    websocket_failure: [url: string, error: string];
    websocket_message: [url: string, message: string, binary: boolean];
    websocket_success: [url: string, response: WebSocket];
    [key: string & {}]: any[];
}

Indexable

  • [key: string & {}]: any[]

Properties

alarm: [id: number]
char: [character: string]
computer_command: string[]
disk: [side: Side]
disk_eject: [side: Side]
file_transfer: [files: TransferredFiles]
http_check: [url: string, success: boolean, error?: string]
http_failure: [url: string, error: string, response?: HTTPResponse]
http_success: [url: string, response: HTTPResponse]
key: [key: number, hold: boolean]
key_up: [key: number]
modem_message: [
    side: Side,
    channel: number,
    replyChannel: number,
    message: unknown,
    distance?: number,
]
monitor_resize: [side: Side]
monitor_touch: [side: Side, x: number, y: number]
mouse_click: [button: MouseButton, x: number, y: number]
mouse_drag: [button: MouseButton, x: number, y: number]
mouse_scroll: [direction: number, x: number, y: number]
mouse_up: [button: MouseButton, x: number, y: number]
paste: [text: string]
peripheral: [side: Side]
peripheral_detach: [side: Side]
rednet_message: [id: number, message: unknown, protocol?: string]
redstone: []
speaker_audio_empty: [side: Side]
task_complete: [
    id: number,
    success: boolean,
    error?: string,
    ...args: unknown[],
]
term_resize: []
terminate: []
timer: [id: number]
turtle_inventory: []
websocket_closed: [url: string, reason?: string, code?: number]
websocket_failure: [url: string, error: string]
websocket_message: [url: string, message: string, binary: boolean]
websocket_success: [url: string, response: WebSocket]