Waits for a specific operating system event to occur
⚠️ NOTE: Requires an active event loop to process events
Returns a promise that resolves when the specified event occurs.
The name of the event to wait for
Optional function to filter events based on their arguments
Optional timeout in milliseconds. If 0, waits indefinitely
A promise that resolves with the event arguments
If the timeout is reached before the event occurs
try { const [itemId, count] = await events.waitForEvent( 'item_pickup', (itemId) => itemId === 64, // Wait for diamond pickup 5000 // Timeout after 5 seconds ); console.log(`Picked up ${count} diamonds!`);} catch (error) { console.log('Timed out waiting for diamond pickup');} Copy
try { const [itemId, count] = await events.waitForEvent( 'item_pickup', (itemId) => itemId === 64, // Wait for diamond pickup 5000 // Timeout after 5 seconds ); console.log(`Picked up ${count} diamonds!`);} catch (error) { console.log('Timed out waiting for diamond pickup');}
Waits for a specific operating system event to occur
⚠️ NOTE: Requires an active event loop to process events
See