Verse Library verse

01 Device

Defines a reusable crafting pad device class that checks player entry and simulates ingredient validation.

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

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

# This is our "Device" class. Think of it as the blueprint for our Crafting Pad.
# Just like a Blueprint in UE, this defines what our object *is* and *does*.
CrystalCraftingPad := class(creative_device):
    # Variables are like the stats on a piece of loot. They change during the game.
    # Here, 'RequiredCrystalCount' is how many crystals (gold) the player needs to craft.
    # Since Crystal is not a real Verse type, we track crafting cost as an int (e.g., gold bars).
    RequiredCrystalCount: int = 1

    # This function runs when a player enters the trigger volume.
    # 'Agent' is the player who walked in.
    OnPlayerEnter(Agent: agent): void =
        # Step 1: Check if the agent is a valid fort_character.
        # This is like checking if the bus is actually flying before you jump out.
        if (Character := Agent.GetFortCharacter[]):
            # Step 2: Check the player's health as a stand-in for inventory check.
            # In real UEFN there is no HasItem API; we simulate the "has ingredient" check
            # by verifying the character is alive (MaxHealth > 0 means they are active).
            HasIngredients: logic = if (Character.GetHealth() > 0.0) then true else false

            # Step 3: Make a decision based on the result.
            # If HasIngredients is TRUE, we proceed. If FALSE, we do nothing.
            if (HasIngredients?):
                # Step 4: The Reward.
                # In real UEFN there is no RemoveItem/GiveItem on agent directly,

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