# ChaosChestScript.v # A device that grants random Flopper items to players who interact with it. # 1. DEFINE THE DEVICE # We tell Verse this script belongs to a specific device instance. # Think of this as labeling the box "DO NOT OPEN" in permanent marker. actor ChaosChestDevice : public Device = { # This is the "Event" that fires when a player interacts. # It's like the storm timer ticking down—it happens at a specific moment. OnInteract(player: Player, _device: Device) -> void = { # 2. PICK A RANDOM FLOPPER # We create a list of possible items (the loot table). # In Verse, we use a "List" to hold multiple items. flopper_options := { ItemData.Snowy_Flopper, ItemData.Flopper, ItemData.Shadow_Flopper, ItemData.Hop_Flopper, ItemData.Vendetta_Flopper, ItemData.Midas_Flopper } # 3. ROLL THE DICE # We pick one item from the list at random. # This is like the random spawn location of a vehicle. selected_item := flopper_options[RandomInt(len(flopper_options))] # 4. GIVE THE ITEM TO THE PLAYER # We need to access the player's inventory. # The Inventory is a "Component" attached to the Player entity. inventory := player.GetInventory() # We grant the item. This is like the "Item Granter" device, # but we're doing it via code, so we can control *which* item. inventory.GrantItem(selected_item) # Optional: Play a sound or spawn particles here for flair! # For now, we just log it to the debug console so you know it worked. Print("Player received a " + ToText(selected_item) + "!") } }