Verse Library verse

01 Fragment

Listens for spawned NPCs and changes a light color to green, then reverts it.

verse-library/signaled-when-a-character-is-spawned-from-the-npc-spawner-device/01-fragment.verse

# This is the main script for our island.
# It connects the spawner to our light.
using { /Fortnite.com/Devices }

# This is our "Container" for the script.
# Think of it as a box that holds our rules.
actor Main is:
    # This is the NPC Spawner we placed in the level.
    # We link it here so we can use it.
    my_spawner: NpcSpawnerDevice = NpcSpawnerDevice{}

    # This is the light we want to change.
    my_light: Light = Light{}

    # This is the "signal" we listen to.
    # It fires when an NPC is born.
    OnNpcSpawned := my_spawner.SpawnedEvent

    # This is the main loop.
    # It waits for the signal to fire.
    on begin() is:
        # We wait for the SpawnedEvent signal.
        # When it fires, the code inside runs.
        for event : OnNpcSpawned do:
            # The NPC has spawned!
            # Let's turn the light green.
            my_light.SetColor(Color{R:0.0, G:1.0, B:0.0})
            
            # Let's wait a moment before turning it off.
            Wait(2.0)

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