Events#

Introduction#

The Events blocks in VEXcode 123 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ó :: hat events

parameter

description

This block has no parameters.

Example

aria-description goes here#
cuando empezó :: hat events
[Drive forward then stop.]
unidad [adelante v]
esperar (2) segundos
deja de conducir

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]

parameter

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

aria-description goes here#
cuando empezó :: hat events
[Turn LED green while the robot moves.]
transmisión [square_drive v]
resplandor [verde v]
cuando recibo [square_drive v] :: hat events
[Move in a square pattern.]
repetir [4]
conducir [adelante v] por [100] [mm 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]

parameter

description

event

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

Example

aria-description goes here#
cuando empezó :: hat events
[Turn LED green while the robot moves.]
transmisión [square_drive v]
resplandor [verde v]
cuando recibo [square_drive v] :: hat events
[Move in a square pattern.]
repetir [4]
conducir [adelante v] por [100] [mm v]
girar [derecha v] por [90] grado

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

parameter

description

event

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

Example

aria-description goes here#
cuando empezó :: hat events
[Turn LED green after robot is done moving.]
transmitir [square_drive v] y esperar
resplandor [verde v]
cuando recibo [square_drive v] :: hat events
[Move in a square pattern.]
repetir [4]
conducir [adelante v] por [100] [mm v]
girar [derecha v] por [90] grado