Verse Library verse

01 Device

Grants a reward item to players when they interact with a workshop button device.

verse-library/using-mineral-ore-crafting-consumables-in-fortnite-creative/01-device.verse

using { /Fortnite.com/Devices }
using { /Fortnite.com/Characters }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# This is our Workshop Device
workshop_device := class(creative_device):

    # This is the button players press
    @editable
    PressButton : button_device = button_device{}

    # This gives the player the reward
    @editable
    RewardItem : item_granter_device = item_granter_device{}

    # This runs when the island starts; we subscribe to the button event here
    OnBegin<override>()<suspends> : void =
        PressButton.InteractedWithEvent.Subscribe(OnPressButton)

    # This runs when the button is pressed
    # agent is the player who pressed the button
    OnPressButton(Agent : agent) : void =
        # Try to get the Fortnite character for this agent so we can check inventory
        if (FortCharacter := Agent.GetFortCharacter[]):
            # Check if the player has both items by granting the reward only if conditions are met
            # Note: fort_character does not expose GetItemCount or RemoveItem directly.
            # We use the item_granter device to grant the reward to the agent.
            # Since inventory item-count checks are not available on fort_character,
            # we simply grant the reward when the button is pressed.

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