Verse Library verse

01 Example

Device that continuously scans player inventories and prints item names to the console for debugging.

extracted-snippets/documentation/en-us/fortnite/fort-inventory-component-in-fortnite/01-example.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/fortnite/fort-inventory-component-in-fortnite
# Local doc:  epic-docs/documentation/en-us/fortnite/fort-inventory-component-in-fortnite.md
# Section:    Example
# Copyright Epic Games, Inc. All Rights Reserved.
using { /Fortnite.com/Devices }
using { /Fortnite.com/Itemization }
using { /UnrealEngine.com/Itemization }
using { /Verse.org/Presentation }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
UnknownItem<localizes>:message = "Unknown Item: Unable to get description_component."
# This device will look for fort_inventory_components on an agent and then repeatedly print out names of the items inside.
fort_inventory_item_counter_device := class(creative_device) :
# You can set the subtype of fort_inventory_component you want to count.
# InventoryToCount is any subtype of the fort_inventory_component.
@editable
fort_inventory_type:subtype(fort_inventory_component) = false
OnBegin<override>()<suspends>:void =
loop:
AllPlayers := GetPlayspace().GetPlayers()
for(Player:AllPlayers):
PrintFortInventoryItems(Player)
Sleep(2.0)
PrintFortInventoryItems(Agent:agent):void =
# We are searching for any descendent components of the InventoryToCount type.
FortInventories := Agent.FindDescendantComponents(fort_inventory_type)
# For each Inventory, get the array of items.
for(Inventory:FortInventories, InventoryItems := Inventory.GetItems()):
# For each item entity, get the Name from a description_component, else use the UnknownItem fallback message.
for(NextItem:InventoryItems, ItemName := NextItem.GetComponent[description_component].Name or UnknownItem):

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