# Import the necessary libraries for devices and events using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our main "Island" class. Think of it as the map itself. # Every island needs one of these to hold the logic. wood_producer_device := class(creative_device): # These are our "Components" (devices) attached to the island. # We declare them here so Verse knows they exist. # Wire each of these up in the UEFN Details panel for this device. @editable TrackerDevice : tracker_device = tracker_device{} @editable ItemGranter : item_granter_device = item_granter_device{} @editable PropManipulator : prop_manipulator_device = prop_manipulator_device{} # This is our "Variable" (Health Bar). # It stores how many times we've chopped the tree since the last reward. # 'var' makes it mutable so we can change it at runtime. var ChopsSinceLastWood : int = 0 # The "OnBegin" function runs once when the island starts. # Like the bus flying over the map before you jump. OnBegin() : void = # Show the prop so the tree is visible when the round starts. PropManipulator.Enable() # Subscribe to the Tracker's CompleteEvent so we hear # every time the Tracker increments. TrackerDevice.CompleteEvent.Subscribe(OnProgressChanged) # This is the "Event Listener." # It watches for the CompleteEvent from the Tracker. # When the Tracker counts a hit, this function fires. # The parameter is the agent whose action caused the change. OnProgressChanged(InAgent : agent) : void = # Increment our local chop counter (like gaining XP toward a level). set ChopsSinceLastWood += 1 # Check if we've chopped enough times (e.g., 5 chops). # This is a Conditional — like checking shield before you heal. if (ChopsSinceLastWood >= 5): # Reset the counter to 0 (like starting a fresh round). set ChopsSinceLastWood = 0 # Tell the Item Granter to give wood NOW. # GrantItemToAll fires the grant for every player on the island. ItemGranter.GrantItemToAll() # Reset the tree visual: disable it, then enable it again. # To the player it looks like the tree just respawned. PropManipulator.Disable() PropManipulator.Enable()