Verse Library verse

01 Device

Displays a temporary welcome text widget to the player upon island load.

verse-library/creating-a-simple-ui-with-hud-widgets-in-verse/01-device.verse

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

# This is our main script class.
# It runs when the game starts.
welcome_message_device := class(creative_device):

    # This runs once when the island loads.
    OnBegin<override>()<suspends> : void =
        # 1. Get the player's screen (The Player UI).
        # We find the first player in the game.
        # GetPlayspace() returns all active players on this island.
        Players := GetPlayspace().GetPlayers()

        # Guard against an empty lobby before continuing.
        if (Player := Players[0], FortPlayer := player[Player], PlayerUI := GetPlayerUI[FortPlayer]):

            # 3. Create a new text_block Widget.
            # This is our "sticker" with text.
            MyText := text_block:
                DefaultText := StringToMessage("Welcome to my Island!")

            # 4. Add the widget to the player's UI.
            # This makes it appear on screen!
            # slot controls layer order; use default_z_order (0) here.
            PlayerUI.AddWidget(MyText, player_ui_slot{ZOrder := 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