Verse Library verse

01 Device

Grants a reward item to a player when a creative button activates, integrating with inventory management.

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

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

crafting_station := class(creative_device):

    @editable
    ItemGranter : item_granter_device = item_granter_device{}

    # Triggered by the Conditional Button's On Success signal in the editor.
    # Wire the Conditional Button's "On Button Activated" event to this device's
    # "Activate" input so this runs only when all conditions pass.
    OnButtonActivated(Agent : agent) : void =
        if (FortCharacter := Agent.GetFortCharacter[]):
            # Grant the crafting reward via the Item Granter device
            ItemGranter.GrantItem(Agent)
            # Note: Item removal (cost) is handled by "Consume Item" actions
            # configured directly on the Conditional Button in the editor.
            Print("Crafting Complete!")

Comments

    Sign in to vote, comment, or suggest an edit. Sign in