Verse Library verse

01 Device

Triggers an item granter when a player meets button conditions to automate crafting rewards.

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

# This is a simple script to show the logic.
# We are checking if a player has two items.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

# A Verse device that wires to a conditional_button_device
# and an item_granter_device placed in the UEFN level.
crafting_station := class(creative_device):

    # Drag the Conditional Button device from the level into this slot.
    @editable
    Button : conditional_button_device = conditional_button_device{}

    # Drag the Item Granter device from the level into this slot.
    @editable
    Granter : item_granter_device = item_granter_device{}

    # OnBegin runs once when the game starts.
    OnBegin<override>()<suspends> : void =
        # Subscribe to the button's success event.
        # TriggeredEvent fires when the player meets ALL key-item conditions.
        Button.TriggeredEvent.Subscribe(OnCraftingTriggered)

    # This function runs when a player successfully triggers the button.
    # note: item consumption is handled automatically by conditional_button_device
    #       when its "Consume Items On Trigger" setting is enabled in the editor.
    OnCraftingTriggered(Agent : agent) : void =
        # Grant the reward item to the player who triggered the button.
        Granter.GrantItem(Agent)

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