# This is our main script file
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# We define a new script type called DrumBeat
DrumBeat := class(creative_device) {
# Here we list the devices we need
# "MyTrigger" is the name we give to the trigger device
@editable
MyTrigger : trigger_device = trigger_device{}
# "MyDrum" is the name we give to the Drum Player device
@editable
MyDrum : Patchwork.drum_player_device = Patchwork.drum_player_device{}
# This function runs when the game starts
OnBegin<override>()<suspends> : void = {
# We listen for the trigger to be pressed
# When it happens, we play the drum
MyTrigger.TriggeredEvent.Subscribe(OnTriggered)
}
# This function is called when the trigger fires
OnTriggered(Agent : ?agent) : void = {
# This line tells the drum to enable (play)
# note: drum_player_device inherits Enable() from patchwork_device
MyDrum.Enable()
}
}
Verse Library
verse
01 Device
Plays a drum audio clip when a specific trigger volume is activated by players.
verse-library/using-patchwork-drum-player-devices-in-fortnite-creative/01-device.verse