Verse Library verse

01 Complete Script

Implements a button-triggered puzzle device that toggles lights using gameplay tags and event handlers.

extracted-snippets/documentation/en-us/uefn/tagged-lights-6-final-result-in-verse/01-complete-script.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/tagged-lights-6-final-result-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/tagged-lights-6-final-result-in-verse.md
# Section:    Complete Script
using { /Fortnite.com/Devices }
using { /Verse.org/Native }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/Simulation/Tags }
using { /Verse.org/Simulation }
# Derive from the `tag` class in the Verse.org/Simulation/Tags module to create a new Gameplay Tag.
puzzle_light := class(tag){}
log_tagged_lights_puzzle := class(log_channel){}
<#
You can use an instance of this class to subscribe to the
InteractedWithEvent of a button_device and have access to per-event properties (in this case, Indices and PuzzleDevice) in your event handler.
Think about it as each button having its personal state and event handler.
Since the class doesn’t have the <concrete> specifier, specifying default values for fields isn’t required.
#>
button_event_handler := class():
# Positions used to access the lights this button controls.
Indices : []int
# tagged_lights_puzzle that created this button_event_handler so we can call functions on it.
PuzzleDevice : tagged_lights_puzzle
OnButtonPressed(InPlayer : agent) : void =
# Tell the PuzzleDevice to toggle the lights at the positions this button controls.
PuzzleDevice.ToggleLights(Indices)
tagged_lights_puzzle := class<concrete>(creative_device):
Logger : log = log{Channel := log_tagged_lights_puzzle}
# Buttons the player uses to interact with the puzzle.
@editable
Buttons : []button_device = array{}

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.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in