Verse Library verse

01 Device

Manages grenade distribution via a dispenser device, handling player interactions and spawn logic.

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

Looking at the errors:

1. `SpawnItem(TheAgent)` - expects `tuple()` not `agent`, so `SpawnItem` takes no arguments
2. `Mod[CombatGrenadeIndex, CombatSpawners.Length]` - needs to be in a failure context
3. Same `SpawnItem` issue on lines 70 and 75

The fix: `SpawnItem()` takes no arguments (it spawns for whoever interacts, triggered by the device), and `Mod[]` needs to be inside an `if`.

Also, `IsActive[]` likely doesn't exist - but the error only shows 4 errors. Let me check: error on line 68 is about `Mod[]` not being in failure context. The `IsActive[]` might compile (as a failable expression in `else if` condition). Actually looking again, `else if (Character.IsActive[])` - `IsActive[]` may not exist but no error is reported for it... wait, there are only 4 errors listed. I'll keep `IsActive[]` as-is since it's not flagged.

For `SpawnItem` - since it takes no agent, we just call `SpawnItem()` and the device handles granting to whoever triggered it.

For `Mod[]` - wrap in `if`.

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

# This is our "Dispenser Device." Think of it as the physical object in the editor.
# In the Scene Graph, this is an Entity with a Script component attached.
grenade_dispenser := class(creative_device):

    # DEVICE REFERENCES: Wire these up in the UEFN editor's Details panel.
    # Each item_spawner_device is configured to spawn a specific grenade type.
    # This is how Verse grants items to players — through spawner devices placed on the island.
    @editable
    CombatGrenadeSpawner : item_spawner_device = item_spawner_device{}   # configured for Grenade

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