Verse Library verse

01 Fragment

Handles player interactions to grant health and items, managing cooldown states for a reusable game mechanic.

verse-library/using-items-gallery-devices-in-fortnite-creative/01-fragment.verse

# This line tells Verse: "Hey, this script belongs to a specific device."
# We link it to the 'HealthStation' prop we placed in the world.
struct MyHealthStation extends Actor:
    # This is our 'Cooldown' variable.
    # Think of it like a 'Ready/Busy' light.
    # 'false' means the station is ready to use.
    IsBusy: bool = false
    
    # This is the timer device.
    # We will use this to wait before resetting the station.
    ResetTimer: Timer = Timer{}
    
    # This is the 'Event' function.
    # It runs automatically when a player presses E on this object.
    # 'Player' is the person who pressed the button.
    OnInteract(Player: Player):
        # CHECK 1: Is the station currently busy?
        # If IsBusy is true, we skip the rest of this code.
        if (IsBusy):
            # Optional: You could play a sound here saying "Wait!"
            return
        
        # CHECK 2: Is the player actually hurt?
        # We check their current health. If it's less than 100, they need help.
        if (Player.GetHealth() < 100):
            
            # REWARD: Give them a Shield Potion.
            # We use the 'Item' device to grant the item directly to the player.
            # Note: In a real scenario, you'd use the Item Device from the gallery.
            # For this script, we simulate the effect by healing them directly.

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