# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/using-chair-devices-in-fortnite-creative
# Local doc: epic-docs/documentation/en-us/fortnite/using-chair-devices-in-fortnite-creative.md
# Section: Using a Chair Device in Verse
using { /Fortnite.com/Devices }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
# A Verse-authored creative device that can be placed in a level
chair_device_verse_example := class(creative_device):
# Reference to the Chair device in the level.
# In the Details panel for this Verse device,
# set this property to your Chair device.
@editable
MyChairDevice:chair_device = chair_device{}
# Runs when the device is started in a running game
OnBegin<override>()<suspends>:void=
# Example for subscribing to an event on the Creative device.
# Signaled when an agent sits on the Chair.
MyChairDevice.SeatedEvent.Subscribe(OnAgentSeated)
# If the Chair is occupied by someone, eject them from the chair.
if:
MyChairDevice.IsOccupied[]
then:
MaybeAgent := MyChairDevice.GetSeatedAgent()
if (Agent := MaybeAgent?):
MyChairDevice.Eject(Agent)
# Grab a random player in the game and seat them in the Chair now that it's guaranteed to be empty.
Players := GetPlayspace().GetPlayers()
RandomIndex := GetRandomInt(0, Players.Length - 1)
if (RandomPlayer := Players[RandomIndex]):
Verse Library
verse
01 Using A Chair Device In Verse
Manages chair seating logic, ejects occupants, and assigns random players via events.
extracted-snippets/documentation/en-us/fortnite/using-chair-devices-in-fortnite-creative/01-using-a-chair-device-in-verse.verse
Sign in free to read the full source 🌴
This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.