Verse Library verse

01 Complete Script

A beginner example showing variable declaration, arithmetic, string conversion, and console printing in a device.

extracted-snippets/documentation/en-us/uefn/learn-code-basics-3-practice-time-in-verse/01-complete-script.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/learn-code-basics-3-practice-time-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/learn-code-basics-3-practice-time-in-verse.md
# Section:    Complete Script
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

hello_world_device := class(creative_device):

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends> : void =

        PotionDamageAmount : float = 20.0
        PotionHealAmount : float = 10.0
        var  PlayerHealth : float = 100.0

        PlayerStatusText : string = "Player health now "
        var EffectOnPlayerText: string = "damaged "

        set PlayerHealth = PlayerHealth - PotionDamageAmount
        Print("The Player was {EffectOnPlayerText + ToString(PotionDamageAmount)}")
        Print("{PlayerStatusText + ToString(PlayerHealth)}")

        set PlayerHealth = PlayerHealth + PotionHealAmount
        set EffectOnPlayerText = "healed "
        Print("The Player was {EffectOnPlayerText + ToString(PotionHealAmount)}")
        Print("{PlayerStatusText + ToString(PlayerHealth)}")
Copy full snippet

Comments

    Sign in to vote, comment, or suggest an edit. Sign in