using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
# This is our custom component for the lantern
LanternLight := class(creative_device):
# We need a light component to make it glow
# note: sphere_light_component is the real Scene Graph light component type
@editable
Light : sphere_light_component = sphere_light_component{}
# We need a mesh component to give it a shape
@editable
Mesh : creative_prop = creative_prop{}
# Tracks whether the lantern is currently on
var LanternOn : logic = false
# This runs once when the game starts
OnBegin<override>()<suspends> : void =
# Turn the light OFF at start so the player can switch it on
Light.SetEnabled(false)
set LanternOn = false
# Print a message to show it worked
Print("Lantern is ready — press E to light it up!")
Verse Library
verse
01 Device
Creates an interactive lantern prop that toggles a light component on or off for player interaction.
verse-library/attaching-components-to-entities-in-the-verse-scene-graph/01-device.verse