# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/coding-device-interactions-in-verse
# Local doc: epic-docs/documentation/en-us/fortnite/coding-device-interactions-in-verse.md
# Section: Awaiting a Creative Device Event
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
make_a_choice_device:= class(creative_device):
@editable
MakeChoice:trigger_device = trigger_device{}
@editable
RedButton:button_device = button_device{}
@editable
BlueButton:button_device = button_device{}
OnBegin<override>()<suspends>:void=
# This waits for the player to step on the trigger and prevents any other code from executing here until this happens.
# This means that if the player interacts with the two button devices, nothing will happen until this event occurs.
MakeChoice.TriggeredEvent.Await()
Print("Make a choice: red button and stay in wonderland, or blue button and wake up back in your bed.")
# Both block expressions execute at the same time in this race expression.
# When the player interacts with one of the buttons, waiting for the other button interaction will cancel.
# This means that the player can only interact with one of the Button devices.
race:
block:
RedButton.InteractedWithEvent.Await()
Print("You chose to stay in wonderland.")
block:
BlueButton.InteractedWithEvent.Await()
Print("You chose to wake up in your bed.")
# If the player interacts with any of the devices at this point, nothing will happen because we only waited for the events to occur once.
Verse Library
verse
04 Awaiting A Creative Device Event
Uses race expressions to handle simultaneous button interactions after a player triggers a starting device.
extracted-snippets/documentation/en-us/fortnite/coding-device-interactions-in-verse/04-awaiting-a-creative-device-event.verse