Verse Library verse

01 Device

Checks player inventory for specific fuel items and changes a crafting station button color based on availability.

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

# We are defining a "Script" which is a container for our logic.
# Think of it like a blueprint for a new device.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

# This is our "Device" definition.
# It’s like creating a custom prop that knows how to behave.
power_bench := class(creative_device):

    # This is a "Variable".
    # It holds the button we want to control.
    # We link it in the editor by dragging the button onto this slot.
    var my_button: button_device = create()

    # This is an "Event".
    # It listens for when the button is pressed.
    # Analogy: Like a tripwire on a trap. When triggered, it runs the code below.
    on_button_pressed := event()

    # This function runs when the event above fires.
    # It checks if the player has the fuel.
    on_button_pressed(played_player: player):
        # 'Has_Item' is a check. Like checking your inventory.
        # We check if the player has an 'Active Powercell'.
        has_fuel: bool = played_player.Has_Item("Active Powercell")

        # If the player has fuel, turn the button GREEN.
        # If not, turn it RED.
        # This gives visual feedback, just like a health bar changing color.
        if has_fuel:

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