using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /Verse.org/SceneGraph } using { /Verse.org/Simulation/Tags } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main script. It runs when the game starts. LootFinder := class(creative_device): # When the game starts, this function runs automatically. OnBegin() : void = # 1. Get the Simulation Entity. # Think of this as grabbing the "Battle Bus" of your island. # GetSimulationEntity[] is a failable function, so we use 'if' to safely unwrap it. if (SimEntity := GetSimulationEntity[]): # 2. Define the tag we are looking for. # We create a "tag type" called 'LootTag'. # This is like defining the color red before you can paint with it. LootTag := loot_tag{} # 3. The Magic Line! # We ask the Simulation Entity to find all descendants with the 'LootTag'. # This returns an array of entities that carry the matching tag. LootEntities := SimEntity.FindDescendantEntitiesWithTag(LootTag, loot_tag) # 4. Loop through the results. # 'for Entity in LootEntities' means "for every object found..." for (FoundEntity : LootEntities): # 5. Do something with the found entity. # For this demo, we'll just print its name to the debug log. # In a real game, you might make it glow, heal it, or destroy it. Print("Found loot item!") loot_tag := class(tag):