Events#

Introduction#

The Events blocks in VEXcode IQ (1st gen) allow for event-driven coding, enabling different parts of a project to run in response to triggers such as project start, received events, or user interactions. Below is a list of available blocks:

when started#

The when started block runs its stack when the project begins. You can have multiple when started blocks to run multiple stacks of blocks at once.

The When started hat block.#
cuando empezó

Parameters

Description

This block has no parameters.

Example

cuando empezó
[Turn around at the start of the project.]
girar hacia el rumbo [180] grados ▶

when I receive event#

The when I receive event block starts a stack when a matching event is broadcast. You can have multiple when I receive event blocks to run multiple stacks of blocks at once.

The When I receive event hat block.#
cuando recibo [my_event v]

Parameters

Description

event

The event to be triggered. Users can select an existing event, create a new one, rename the selected event, or delete it.

Example

cuando empezó
[Display a message and turn at the same time.]
esperar hasta <¿Botón del cerebro [Check v] presionado?>
transmisión [turn v]
cuando recibo [turn v]
imprimir [Received!] en [Brain v] ▶
girar [derecha v] por [90] grado ▶

broadcast event#

The broadcast event block triggers any matching when I receive event hat block. It does not pause the execution of the stack and continues running the next block immediately.

The Broadcast event stack block.#
transmisión [message1 v]

Parameters

Description

event

The event to trigger. Users can select an existing event, create a new one, rename the selected event, or delete it.

Example

cuando empezó
[Play a sound when a button is pressed while turning.]
para siempre
si <¿Botón del cerebro [Izquierda v] presionado?> entonces
transmisión [button_press v]
demás
turno [derecha v]
cuando recibo [button_press v]
reproducir sonido [alarma v]

broadcast event and wait#

The broadcast event and wait block triggers an event, then pauses execution of the current stack until all triggered when I receive event block stacks have completed.

The Broadcast event and wait stack block.#
transmitir [message1 v] y esperar

Parameters

Description

event

The event to trigger. Users can select an existing event, create a new one, rename the selected event, or delete it.

Example

cuando empezó
[Move after the Brain's Check button is pressed.]
esperar hasta <¿Botón del cerebro [Check v] presionado?>
transmitir [forward_and_turn v] y esperar
imprimir [Movement done.] en [Brain v] ▶
cuando recibo [forward_and_turn v]
unidad [adelante v] para [100] [mm v] ▶
girar [derecha v] por [90] grado ▶