# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/item-details-component-in-fortnite
# Local doc: epic-docs/documentation/en-us/fortnite/item-details-component-in-fortnite.md
# Section: Verse: Description
# Copyright Epic Games, Inc. All Rights Reserved.
using { /Verse.org/SceneGraph }
using { /Verse.org/Presentation }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
# The text we want to use for names in our description_component must be declared outside of the class.
Name_Alan<localizes>:message = "Alan "
Name_Bill<localizes>:message = "Bill "
Name_Chloe<localizes>:message = "Chloe "
# We have a default message to use if we are unable to get a Name from a description_component.
Name_Invalid<localizes>:message = "Invalid"
# This component will set a random name when it is added to the scene.
random_name_description_component := class(description_component) :
ListOfNames:[]message = array{ Name_Alan, Name_Bill, Name_Chloe }
# Here we set Name to be the return of GetRandomName().
OnAddedToScene<override>():void =
set Name = GetRandomName()
# This function returns a random entry from our ListOfNames array. If it fails, it uses the backup invalid message.
GetRandomName():message =
if(RandomName := Shuffle(ListOfNames)[0]):
RandomName
else:
Name_Invalid
Verse Library
verse
01 Verse Description
Assigns a random name from a list to a component when spawned, with fallback logic for empty arrays.
extracted-snippets/documentation/en-us/fortnite/item-details-component-in-fortnite/01-verse-description.verse