Verse Library verse

01 Standalone

Activates a button to reward players with items, handling economy transactions.

verse-library/using-gold-consumables-in-fortnite-creative/01-standalone.verse

# This is a comment. It's like a sticky note on your code that the game ignores.
# We are defining a script that runs on the ShopButton entity.

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our main script block. Think of it as the "Brain" of the button.
BlackMarketLogic := class(creative_script):

    # This is a VARIABLE. It’s a container for our button.
    # We call it 'shop_button' and it holds a 'conditional_button_device'.
    shop_button: conditional_button_device = conditional_button_device{}

    # This is another VARIABLE for our item granter.
    # We call it 'reward_granter'.
    reward_granter: item_granter_device = item_granter_device{}

    # This function runs when the script starts. It's like loading the map.
    OnBegin<override>()<suspends>: void =
        # Here we are "Registering" an event.
        # Think of this as setting up a trap. We don't know when it triggers,
        # but when it does, we want to run 'OnButtonPressed'.
        # shop_button.ActivatedEvent.Register(self, OnButtonPressed)
        # Note: In Verse, we often use 'Bind' or direct event registration.
        # For simplicity in this beginner example, we'll assume a direct trigger flow.
        
        # Let's register the event listener.
        shop_button.ActivatedEvent += func(event: conditional_button_device_activated_event):
            OnButtonPressed(event)

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