# This is our main script file. It tells the game engine what to do. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a "creative_device" class. Think of this as the brain of our island. # It holds all the logic. In UEFN, this class is placed directly on your island. healing_zone_script := class(creative_device): # This is a VARIABLE. # It's a box that will hold a reference to our Trigger Volume. # We call it "Trigger" because it's the thing that detects players. # The @editable tag makes it visible and assignable in the UEFN details panel. @editable Trigger : trigger_device = trigger_device{} # This is another VARIABLE. # It will hold a reference to our Item Granter. # We call it "ItemGranter" because it gives stuff to players. @editable ItemGranter : item_granter_device = item_granter_device{} # This is a FUNCTION. # A function is a set of instructions that runs when called. # Here, we define what happens when the trigger is activated. # It receives the agent (player) who stepped into the trigger zone. # The agent parameter is optional (?agent) because the trigger event # passes an optional agent value. OnTriggerActivated(Agent : ?agent) : void = # Unwrap the optional agent before using it. if (A := Agent?): # This line tells the Item Granter to grant an item to the player # who triggered the volume. # "GrantItem" is the action, "A" is who gets it. ItemGranter.GrantItem(A) # This is the MAIN ENTRY POINT. # When the island starts, this function runs first. # Every creative_device has an OnBegin() that the engine calls automatically. OnBegin() : void = # Now, we connect the event. # When "Trigger" is activated, run the "OnTriggerActivated" function. # This is like plugging a wire from the sensor to the motor. # Note: in UEFN you drag-assign Trigger and ItemGranter in the details # panel rather than searching by name at runtime. Trigger.TriggeredEvent.Subscribe(OnTriggerActivated)